Skip to content

Instantly share code, notes, and snippets.

@hemanth22
Forked from Nikila99gimhan/aks-deploy(cd).yml
Created October 12, 2022 07:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hemanth22/b14da0e11f82713fa3acc4053645c9aa to your computer and use it in GitHub Desktop.
Save hemanth22/b14da0e11f82713fa3acc4053645c9aa to your computer and use it in GitHub Desktop.
# Logs in to the Azure Container Registry
- uses: Azure/docker-login@v1
with:
login-server: ${{ env.AZURE_CONTAINER_REGISTRY }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
# Build and push image to Azure Container Registry
- name: Build and push image to Azure Container Registry
run: |
docker build . -t ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ env.CONTAINER_NAME }}:${{ github.sha }}
docker push ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ env.CONTAINER_NAME }}:${{ github.sha }}
# Retrieves your Azure Kubernetes Service cluster's kubeconfig file
- name: Get K8s context
uses: Azure/aks-set-context@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
cluster-name: ${{ env.CLUSTER_NAME }}
resource-group: ${{ env.RESOURCE_GROUP }}
# Create Image Pull Secret
- name: Create Image Pull Secret
uses: Azure/k8s-create-secret@v1
with:
container-registry-url: ${{ env.AZURE_CONTAINER_REGISTRY }}
container-registry-username: ${{ secrets.ACR_USERNAME }}
container-registry-password: ${{ secrets.ACR_PASSWORD }}
secret-name: ${{ env.IMAGE_PULL_SECRET_NAME }}
# Deploy to AKS
- name: Deploy to AKS
uses: Azure/k8s-deploy@v1
with:
manifests: |
manifests/deployment.yml
manifests/service.yml
images: |
${{ env.AZURE_CONTAINER_REGISTRY }}/${{ env.CONTAINER_NAME }}:${{ github.sha }}
imagepullsecrets: |
${{ env.IMAGE_PULL_SECRET_NAME }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment