Merge branch 'main' into patch-16

This commit is contained in:
Sampark Sharma
2022-03-14 13:08:51 +05:30
committed by GitHub
21 changed files with 525 additions and 59 deletions
+5 -1
View File
@@ -1,6 +1,10 @@
name: MSBuild name: MSBuild
on: [push] on:
push:
branches: [ $default-branch ]
pull_request:
branches: [ $default-branch ]
env: env:
# Path to the solution file relative to the root of the project. # Path to the solution file relative to the root of the project.
+5
View File
@@ -42,8 +42,13 @@ on:
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
jobs: jobs:
Trigger APIsec scan: Trigger APIsec scan:
permissions:
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
+6
View File
@@ -17,8 +17,14 @@ on:
schedule: schedule:
- cron: $cron-weekly - cron: $cron-weekly
permissions:
contents: read
jobs: jobs:
brakeman-scan: brakeman-scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: Brakeman Scan name: Brakeman Scan
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
+6
View File
@@ -22,8 +22,14 @@ on:
schedule: schedule:
- cron: $cron-weekly - cron: $cron-weekly
permissions:
contents: read
jobs: jobs:
codacy-security-scan: codacy-security-scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: Codacy Security Scan name: Codacy Security Scan
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
+6
View File
@@ -13,8 +13,14 @@ on:
schedule: schedule:
- cron: $cron-weekly - cron: $cron-weekly
permissions:
contents: read
jobs: jobs:
mobile-security: mobile-security:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
+6
View File
@@ -20,8 +20,14 @@ env:
# Path to the CMake build directory. # Path to the CMake build directory.
build: '${{ github.workspace }}/build' build: '${{ github.workspace }}/build'
permissions:
contents: read
jobs: jobs:
analyze: analyze:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: Analyze name: Analyze
runs-on: windows-latest runs-on: windows-latest
+6
View File
@@ -17,8 +17,14 @@ on:
schedule: schedule:
- cron: $cron-weekly - cron: $cron-weekly
permissions:
contents: read
jobs: jobs:
njsscan: njsscan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: njsscan code scanning name: njsscan code scanning
steps: steps:
+6
View File
@@ -21,8 +21,14 @@ on:
schedule: schedule:
- cron: $cron-weekly - cron: $cron-weekly
permissions:
contents: read
jobs: jobs:
prisma_cloud_iac_scan: prisma_cloud_iac_scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Run Prisma Cloud IaC Scan to check name: Run Prisma Cloud IaC Scan to check
steps: steps:
+1 -1
View File
@@ -27,7 +27,7 @@ jobs:
persist-credentials: false persist-credentials: false
- name: "Run analysis" - name: "Run analysis"
uses: ossf/scorecard-action@c8416b0b2bf627c349ca92fc8e3de51a64b005cf # v1.0.2 uses: ossf/scorecard-action@c1aec4ac820532bab364f02a81873c555a0ba3a1 # v1.0.4
with: with:
results_file: results.sarif results_file: results.sarif
results_format: sarif results_format: sarif
+6
View File
@@ -19,8 +19,14 @@ on:
schedule: schedule:
- cron: $cron-weekly - cron: $cron-weekly
permissions:
contents: read
jobs: jobs:
semgrep: semgrep:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: Scan name: Scan
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
+6
View File
@@ -37,8 +37,14 @@ on:
schedule: schedule:
- cron: $cron-weekly - cron: $cron-weekly
permissions:
contents: read
jobs: jobs:
stackhawk: stackhawk:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for stackhawk/hawkscan-action to upload code scanning alert info
name: StackHawk name: StackHawk
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
+7
View File
@@ -13,10 +13,17 @@ on:
schedule: schedule:
- cron: $cron-weekly - cron: $cron-weekly
permissions:
contents: read
jobs: jobs:
build: build:
permissions:
checks: write # for sysdiglabs/scan-action to publish the checks
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
+6
View File
@@ -17,10 +17,16 @@ on:
- cron: $cron-weekly - cron: $cron-weekly
# A workflow run is made up of one or more jobs that can run sequentially or in parallel # A workflow run is made up of one or more jobs that can run sequentially or in parallel
permissions:
contents: read
jobs: jobs:
# This workflow contains a job to build and submit pipeline scan, you will need to customize the build process accordingly and make sure the artifact you build is used as the file input to the pipeline scan file parameter # This workflow contains a job to build and submit pipeline scan, you will need to customize the build process accordingly and make sure the artifact you build is used as the file input to the pipeline scan file parameter
build-and-pipeline-scan: build-and-pipeline-scan:
# The type of runner that the job will run on # The type of runner that the job will run on
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -0,0 +1,122 @@
# This workflow will build and push an application to a Azure Kubernetes Service (AKS) cluster when you push your code
#
# This workflow assumes you have already created the target AKS cluster and have created an Azure Container Registry (ACR)
# For instructions see:
# - https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal
# - https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal
# - https://github.com/Azure/aks-create-action
#
# To configure this workflow:
#
# 1. Set the following secrets in your repository (instructions for getting these
# https://github.com/Azure/login#configure-a-service-principal-with-a-federated-credential-to-use-oidc-based-authentication):
# - AZURE_CLIENT_ID
# - AZURE_TENANT_ID
# - AZURE_SUBSCRIPTION_ID
#
# 2. Set the following environment variables (or replace the values below):
# - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR)
# - RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_NAME (name of your AKS cluster)
# - CONTAINER_NAME (name of the container image you would like to push up to your ACR)
# - SECRET_NAME (name of the secret associated with pulling your ACR image)
#
# 3. Choose the appropriate render engine for the bake step https://github.com/Azure/k8s-bake. The config below assumes Helm.
# Set your helmChart, overrideFiles, overrides, and helm-version to suit your configuration.
# - CHART_PATH (path to your helm chart)
# - CHART_OVERRIDE_PATH (path to your helm chart with override values)
#
# For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
# For more options with the actions used below please refer to https://github.com/Azure/login
name: Build and deploy an app to AKS with Helm
on:
push:
branches:
- $default-branch
workflow_dispatch:
env:
AZURE_CONTAINER_REGISTRY: "your-azure-container-registry"
CONTAINER_NAME: "your-container-name"
RESOURCE_GROUP: "your-resource-group"
CLUSTER_NAME: "your-cluster-name"
IMAGE_PULL_SECRET_NAME: "your-image-pull-secret-name"
CHART_PATH: "your-chart-path"
CHART_OVERRIDE_PATH: "your-chart-override-path"
jobs:
build:
permissions:
actions: read
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
# Checks out the repository this file is in
- uses: actions/checkout@master
# Logs in with your Azure credentials
- name: Azure login
uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# Builds and pushes an image up to your Azure Container Registry
- name: Build and push image to ACR
run: |
az acr build --image ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} .
# Retrieves your Azure Kubernetes Service cluster's kubeconfig file
- name: Get K8s context
uses: azure/[email protected]
with:
resource-group: ${{ env.RESOURCE_GROUP }}
cluster-name: ${{ env.CLUSTER_NAME }}
# Retrieves the credentials for pulling images from your Azure Container Registry
- name: Get ACR credentials
run: |
az acr update -n ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} --admin-enabled true
ACR_USERNAME=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query username -o tsv)
ACR_PASSWORD=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query passwords[0].value -o tsv)
echo "::set-output name=username::${ACR_USERNAME}"
echo "::set-output name=password::${ACR_PASSWORD}"
id: get-acr-creds
# Creates a kubernetes secret on your Azure Kubernetes Service cluster that matches up to the credentials from the last step
- name: Create K8s secret for pulling image from ACR
uses: Azure/[email protected]
with:
container-registry-url: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io
container-registry-username: ${{ steps.get-acr-creds.outputs.username }}
container-registry-password: ${{ steps.get-acr-creds.outputs.password }}
secret-name: ${{ env.IMAGE_PULL_SECRET_NAME }}
# Runs Helm to create manifest files
- name: Bake deployment
uses: azure/[email protected]
with:
renderEngine: 'helm'
helmChart: ${{ env.CHART_PATH }}
overrideFiles: ${{ env.CHART_OVERRIDE_PATH }}
overrides: |
replicas:2
helm-version: 'latest'
id: bake
# Deploys application based on manifest files from previous step
- name: Deploy application
uses: Azure/[email protected]
with:
action: deploy
manifests: ${{ steps.bake.outputs.manifestsBundle }}
images: |
${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
imagepullsecrets: |
${{ env.IMAGE_PULL_SECRET_NAME }}
@@ -0,0 +1,111 @@
# This workflow will build and push an application to a Azure Kubernetes Service (AKS) cluster when you push your code
#
# This workflow assumes you have already created the target AKS cluster and have created an Azure Container Registry (ACR)
# For instructions see:
# - https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal
# - https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal
# - https://github.com/Azure/aks-create-action
#
# To configure this workflow:
#
# 1. Set the following secrets in your repository (instructions for getting these
# https://github.com/Azure/login#configure-a-service-principal-with-a-federated-credential-to-use-oidc-based-authentication):
# - AZURE_CLIENT_ID
# - AZURE_TENANT_ID
# - AZURE_SUBSCRIPTION_ID
#
# 2. Set the following environment variables (or replace the values below):
# - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR)
# - RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_NAME (name of your AKS cluster)
# - CONTAINER_NAME (name of the container image you would like to push up to your ACR)
# - SECRET_NAME (name of the secret associated with pulling your ACR image)
#
# 3. Choose the appropriate render engine for the bake step https://github.com/Azure/k8s-bake. The config below assumes Kompose.
# Set your dockerComposeFile and kompose-version to suit your configuration.
# - DOCKER_COMPOSE_FILE_PATH (the path where your Kompose deployment manifest is located)
#
# For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
# For more options with the actions used below please refer to https://github.com/Azure/login
name: Build and deploy an app to AKS with Kompose
env:
AZURE_CONTAINER_REGISTRY: "your-azure-container-registry"
CONTAINER_NAME: "your-container-name"
RESOURCE_GROUP: "your-resource-group"
CLUSTER_NAME: "your-cluster-name"
IMAGE_PULL_SECRET_NAME: "your-image-pull-secret-name"
DOCKER_COMPOSE_FILE_PATH: "your-docker-compose-file-path"
jobs:
build:
permissions:
actions: read
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
# Checks out the repository this file is in
- uses: actions/checkout@master
# Logs in with your Azure credentials
- name: Azure login
uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# Builds and pushes an image up to your Azure Container Registry
- name: Build and push image to ACR
run: |
az acr build --image ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} .
# Retrieves your Azure Kubernetes Service cluster's kubeconfig file
- name: Get K8s context
uses: azure/[email protected]
with:
resource-group: ${{ env.RESOURCE_GROUP }}
cluster-name: ${{ env.CLUSTER_NAME }}
# Retrieves the credentials for pulling images from your Azure Container Registry
- name: Get ACR credentials
run: |
az acr update -n ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} --admin-enabled true
ACR_USERNAME=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query username -o tsv)
ACR_PASSWORD=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query passwords[0].value -o tsv)
echo "::set-output name=username::${ACR_USERNAME}"
echo "::set-output name=password::${ACR_PASSWORD}"
id: get-acr-creds
# Creates a kubernetes secret on your Azure Kubernetes Service cluster that matches up to the credentials from the last step
- name: Create K8s secret for pulling image from ACR
uses: Azure/[email protected]
with:
container-registry-url: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io
container-registry-username: ${{ steps.get-acr-creds.outputs.username }}
container-registry-password: ${{ steps.get-acr-creds.outputs.password }}
secret-name: ${{ env.IMAGE_PULL_SECRET_NAME }}
# Runs Kompose to create manifest files
- name: Bake deployment
uses: azure/[email protected]
with:
renderEngine: 'kompose'
dockerComposeFile: ${{ env.DOCKER_COMPOSE_FILE_PATH }}
kompose-version: 'latest'
id: bake
# Deploys application based on manifest files from previous step
- name: Deploy application
uses: Azure/[email protected]
with:
action: deploy
manifests: ${{ steps.bake.outputs.manifestsBundle }}
images: |
${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
imagepullsecrets: |
${{ env.IMAGE_PULL_SECRET_NAME }}
@@ -0,0 +1,117 @@
# This workflow will build and push an application to a Azure Kubernetes Service (AKS) cluster when you push your code
#
# This workflow assumes you have already created the target AKS cluster and have created an Azure Container Registry (ACR)
# For instructions see:
# - https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal
# - https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal
# - https://github.com/Azure/aks-create-action
#
# To configure this workflow:
#
# 1. Set the following secrets in your repository (instructions for getting these
# https://github.com/Azure/login#configure-a-service-principal-with-a-federated-credential-to-use-oidc-based-authentication):
# - AZURE_CLIENT_ID
# - AZURE_TENANT_ID
# - AZURE_SUBSCRIPTION_ID
#
# 2. Set the following environment variables (or replace the values below):
# - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR)
# - RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_NAME (name of your AKS cluster)
# - CONTAINER_NAME (name of the container image you would like to push up to your ACR)
# - SECRET_NAME (name of the secret associated with pulling your ACR image)
#
# 3. Choose the appropriate render engine for the bake step https://github.com/Azure/k8s-bake. The config below assumes Kustomize.
# Set your kustomizationPath and kubectl-version to suit your configuration.
# - KUSTOMIZE_PATH (the path where your Kustomize manifests are located)
#
# For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
# For more options with the actions used below please refer to https://github.com/Azure/login
name: Build and deploy an app to AKS with Kustomize
on:
push:
branches:
- $default-branch
workflow_dispatch:
env:
AZURE_CONTAINER_REGISTRY: "your-azure-container-registry"
CONTAINER_NAME: "your-container-name"
RESOURCE_GROUP: "your-resource-group"
CLUSTER_NAME: "your-cluster-name"
IMAGE_PULL_SECRET_NAME: "your-image-pull-secret-name"
KUSTOMIZE_PATH: "your-kustomize-path"
jobs:
build:
permissions:
actions: read
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
# Checks out the repository this file is in
- uses: actions/checkout@master
# Logs in with your Azure credentials
- name: Azure login
uses: azure/[email protected]
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# Builds and pushes an image up to your Azure Container Registry
- name: Build and push image to ACR
run: |
az acr build --image ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} .
# Retrieves your Azure Kubernetes Service cluster's kubeconfig file
- name: Get K8s context
uses: azure/[email protected]
with:
resource-group: ${{ env.RESOURCE_GROUP }}
cluster-name: ${{ env.CLUSTER_NAME }}
# Retrieves the credentials for pulling images from your Azure Container Registry
- name: Get ACR credentials
run: |
az acr update -n ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} --admin-enabled true
ACR_USERNAME=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query username -o tsv)
ACR_PASSWORD=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query passwords[0].value -o tsv)
echo "::set-output name=username::${ACR_USERNAME}"
echo "::set-output name=password::${ACR_PASSWORD}"
id: get-acr-creds
# Creates a kubernetes secret on your Azure Kubernetes Service cluster that matches up to the credentials from the last step
- name: Create K8s secret for pulling image from ACR
uses: Azure/[email protected]
with:
container-registry-url: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io
container-registry-username: ${{ steps.get-acr-creds.outputs.username }}
container-registry-password: ${{ steps.get-acr-creds.outputs.password }}
secret-name: ${{ env.IMAGE_PULL_SECRET_NAME }}
# Runs Kustomize to create manifest files
- name: Bake deployment
uses: azure/[email protected]
with:
renderEngine: 'kustomize'
kustomizationPath: ${{ env.KUSTOMIZE_PATH }}
kubectl-version: latest
id: bake
# Deploys application based on manifest files from previous step
- name: Deploy application
uses: Azure/[email protected]
with:
action: deploy
manifests: ${{ steps.bake.outputs.manifestsBundle }}
images: |
${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
imagepullsecrets: |
${{ env.IMAGE_PULL_SECRET_NAME }}
+74 -49
View File
@@ -1,80 +1,105 @@
# This workflow will build and push an application to a Azure Kubernetes Service (AKS) cluster when you push your code # This workflow will build and push an application to a Azure Kubernetes Service (AKS) cluster when you push your code
# #
# This workflow assumes you have already created the target AKS cluster and have created an Azure Container Registry (ACR) # This workflow assumes you have already created the target AKS cluster and have created an Azure Container Registry (ACR)
# For instructions see https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal # For instructions see:
# https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal # - https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal
# https://github.com/Azure/aks-create-action # - https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal
# - https://github.com/Azure/aks-create-action
# #
# To configure this workflow: # To configure this workflow:
# #
# 1. Set the following secrets in your repository: # 1. Set the following secrets in your repository (instructions for getting these
# - AZURE_CREDENTIALS (instructions for getting this https://github.com/Azure/login#configure-a-service-principal-with-a-secret) # https://github.com/Azure/login#configure-a-service-principal-with-a-federated-credential-to-use-oidc-based-authentication):
# - AZURE_CLIENT_ID
# - AZURE_TENANT_ID
# - AZURE_SUBSCRIPTION_ID
# #
# 2. Set the following environment variables (or replace the values below): # 2. Set the following environment variables (or replace the values below):
# - AZURE_CONTAINER_REGISTRY (name of your container registry) # - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR)
# - PROJECT_NAME
# - RESOURCE_GROUP (where your cluster is deployed) # - RESOURCE_GROUP (where your cluster is deployed)
# - CLUSTER_NAME (name of your AKS cluster) # - CLUSTER_NAME (name of your AKS cluster)
# # - CONTAINER_NAME (name of the container image you would like to push up to your ACR)
# 3. Choose the approrpiate render engine for the bake step https://github.com/Azure/k8s-bake. The config below assumes helm, then set # - SECRET_NAME (name of the secret associated with pulling your ACR image)
# any needed environment variables such as: # - DEPLOYMENT_MANIFEST_PATH (path to the manifest yaml for your deployment)
# - CHART_PATH
# - CHART_OVERRIDE_PATH
# #
# For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions # For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples # For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
# For more options with the actions used below please see the folllowing # For more options with the actions used below please refer to https://github.com/Azure/login
# https://github.com/Azure/login
# https://github.com/Azure/aks-set-context
# https://github.com/marketplace/actions/azure-cli-action
# https://github.com/Azure/k8s-bake
# https://github.com/Azure/k8s-deploy
on: [push] name: Build and deploy an app to AKS
on:
push:
branches:
- $default-branch
workflow_dispatch:
env:
AZURE_CONTAINER_REGISTRY: "your-azure-container-registry"
CONTAINER_NAME: "your-container-name"
RESOURCE_GROUP: "your-resource-group"
CLUSTER_NAME: "your-cluster-name"
IMAGE_PULL_SECRET_NAME: "your-image-pull-secret-name"
DEPLOYMENT_MANIFEST_PATH: 'your-deployment-manifest-path'
jobs: jobs:
build: build:
permissions:
actions: read
contents: read
id-token: write
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# Checks out the repository this file is in
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Azure Login # Logs in with your Azure credentials
uses: azure/login@v1 - name: Azure login
uses: azure/[email protected]
with: with:
creds: ${{ secrets.AZURE_CREDENTIALS }} client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Build image on ACR # Builds and pushes an image up to your Azure Container Registry
uses: azure/CLI@v1 - name: Build and push image to ACR
run: |
az acr build --image ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} .
# Retrieves your Azure Kubernetes Service cluster's kubeconfig file
- name: Get K8s context
uses: azure/[email protected]
with: with:
azcliversion: 2.29.1 resource-group: ${{ env.RESOURCE_GROUP }}
inlineScript: | cluster-name: ${{ env.CLUSTER_NAME }}
az configure --defaults acr=${{ env.AZURE_CONTAINER_REGISTRY }}
az acr build -t -t ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.PROJECT_NAME }}:${{ github.sha }}
- name: Gets K8s context # Retrieves the credentials for pulling images from your Azure Container Registry
uses: azure/aks-set-context@v1 - name: Get ACR credentials
run: |
az acr update -n ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.RESOURCE_GROUP }} --admin-enabled true
ACR_USERNAME=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query username -o tsv)
ACR_PASSWORD=$(az acr credential show -g ${{ env.RESOURCE_GROUP }} -n ${{ env.AZURE_CONTAINER_REGISTRY }} --query passwords[0].value -o tsv)
echo "::set-output name=username::${ACR_USERNAME}"
echo "::set-output name=password::${ACR_PASSWORD}"
id: get-acr-creds
# Creates a kubernetes secret on your Azure Kubernetes Service cluster that matches up to the credentials from the last step
- name: Create K8s secret for pulling image from ACR
uses: Azure/[email protected]
with: with:
creds: ${{ secrets.AZURE_CREDENTIALS }} container-registry-url: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io
resource-group: ${{ env.RESOURCE_GROUP }} container-registry-username: ${{ steps.get-acr-creds.outputs.username }}
cluster-name: ${{ env.CLUSTER_NAME }} container-registry-password: ${{ steps.get-acr-creds.outputs.password }}
id: login secret-name: ${{ env.IMAGE_PULL_SECRET_NAME }}
- name: Configure deployment
uses: azure/k8s-bake@v1
with:
renderEngine: 'helm'
helmChart: ${{ env.CHART_PATH }}
overrideFiles: ${{ env.CHART_OVERRIDE_PATH }}
overrides: |
replicas:2
helm-version: 'latest'
id: bake
# Deploys application based on given manifest file
- name: Deploys application - name: Deploys application
- uses: Azure/k8s-deploy@v1 uses: Azure/k8s-deploy@v3.0
with: with:
manifests: ${{ steps.bake.outputs.manifestsBundle }} action: deploy
manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }}
images: | images: |
${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.PROJECT_NAME }}:${{ github.sha }} ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
imagepullsecrets: | imagepullsecrets: |
${{ env.PROJECT_NAME }} ${{ env.IMAGE_PULL_SECRET_NAME }}
@@ -0,0 +1,7 @@
{
"name": "Deploy to AKS with Helm",
"description": "Deploy an application to an Azure Kubernetes Service cluster using Helm",
"creator": "Microsoft Azure",
"iconName": "azure",
"categories": ["Deployment", "Helm", "Kubernetes", "Dockerfile"]
}
@@ -0,0 +1,7 @@
{
"name": "Deploy to AKS with Kompose",
"description": "Deploy an application to an Azure Kubernetes Service cluster using Kompose",
"creator": "Microsoft Azure",
"iconName": "azure",
"categories": ["Deployment", "Kompose", "Kubernetes", "Dockerfile"]
}
@@ -0,0 +1,7 @@
{
"name": "Deploy to AKS with Kustomize",
"description": "Deploy an application to an Azure Kubernetes Service cluster using Kustomize",
"creator": "Microsoft Azure",
"iconName": "azure",
"categories": ["Deployment", "Kustomize", "Kubernetes", "Dockerfile"]
}
@@ -1,7 +1,7 @@
{ {
"name": "Deploy to a AKS Cluster", "name": "Deploy to AKS",
"description": "Deploy an application to a Azure Kubernetes Service Cluster using Azure Credentials", "description": "Deploy an application to an Azure Kubernetes Service cluster",
"creator": "Microsoft Azure", "creator": "Microsoft Azure",
"iconName": "azure", "iconName": "azure",
"categories": ["Deployment", "Kompose", "Helm", "Kustomize", "Kubernetes", "Dockerfile"] "categories": ["Deployment", "Kubernetes", "Dockerfile"]
} }