forked from actions/starter-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'actions:main' into main
- Loading branch information
Showing
14 changed files
with
347 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
# 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) | ||
# The ACR should be attached to the AKS cluster | ||
# 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://learn.microsoft.com/en-us/azure/aks/cluster-container-registry-integration?tabs=azure-cli#configure-acr-integration-for-existing-aks-clusters | ||
# - https://github.com/Azure/aks-create-action | ||
# | ||
# To configure this workflow: | ||
# | ||
# 1. Set the following secrets in your repository (instructions for getting these | ||
# 1. Set the following secrets in your repository (instructions for getting these | ||
# https://docs.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-cli%2Clinux)): | ||
# - AZURE_CLIENT_ID | ||
# - AZURE_TENANT_ID | ||
|
@@ -34,15 +36,14 @@ name: Build and deploy an app to AKS with Helm | |
|
||
on: | ||
push: | ||
branches: [ $default-branch ] | ||
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" | ||
|
||
|
@@ -53,109 +54,65 @@ jobs: | |
id-token: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checks out the repository this file is in | ||
- uses: actions/checkout@v3 | ||
|
||
# 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 }} . | ||
# Checks out the repository this file is in | ||
- uses: actions/checkout@v3 | ||
|
||
createSecret: | ||
permissions: | ||
contents: read | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
# 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 }} | ||
# 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 }} | ||
|
||
# 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 "::add-mask::${ACR_USERNAME}" | ||
echo "::set-output name=username::${ACR_USERNAME}" | ||
echo "::add-mask::${ACR_PASSWORD}" | ||
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 }} | ||
# 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 }} . | ||
deploy: | ||
permissions: | ||
actions: read | ||
contents: read | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
needs: [buildImage, createSecret] | ||
needs: [buildImage] | ||
steps: | ||
# Checks out the repository this file is in | ||
- uses: actions/checkout@v3 | ||
# Logs in with your Azure credentials | ||
- name: Azure login | ||
uses: azure/[email protected].3 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
# Retrieves your Azure Kubernetes Service cluster's kubeconfig file | ||
- name: Get K8s context | ||
uses: azure/aks-set-context@v2.0 | ||
with: | ||
resource-group: ${{ env.RESOURCE_GROUP }} | ||
cluster-name: ${{ env.CLUSTER_NAME }} | ||
# Checks out the repository this file is in | ||
- uses: actions/checkout@v3 | ||
|
||
# Logs in with your Azure credentials | ||
- name: Azure login | ||
uses: azure/[email protected].6 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
# Retrieves your Azure Kubernetes Service cluster's kubeconfig file | ||
- name: Get K8s context | ||
uses: azure/aks-set-context@v3 | ||
with: | ||
resource-group: ${{ env.RESOURCE_GROUP }} | ||
cluster-name: ${{ env.CLUSTER_NAME }} | ||
|
||
# Runs Helm to create manifest files | ||
- name: Bake deployment | ||
uses: azure/k8s-bake@v2.1 | ||
with: | ||
renderEngine: 'helm' | ||
helmChart: ${{ env.CHART_PATH }} | ||
overrideFiles: ${{ env.CHART_OVERRIDE_PATH }} | ||
overrides: | | ||
replicas:2 | ||
helm-version: 'latest' | ||
id: bake | ||
# Runs Helm to create manifest files | ||
- name: Bake deployment | ||
uses: azure/k8s-bake@v2 | ||
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 }} | ||
# Deploys application based on manifest files from previous step | ||
- name: Deploy application | ||
uses: Azure/k8s-deploy@v4 | ||
with: | ||
action: deploy | ||
manifests: ${{ steps.bake.outputs.manifestsBundle }} | ||
images: | | ||
${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} |
Oops, something went wrong.