Skip to content

Instantly share code, notes, and snippets.

@hadoan
Created September 19, 2021 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadoan/2734e792421f25bacdc18c51ba875d38 to your computer and use it in GitHub Desktop.
Save hadoan/2734e792421f25bacdc18c51ba875d38 to your computer and use it in GitHub Desktop.
env:
REGISTRY_NAME: your-container-register-name
CLUSTER_NAME: your-aks-cluster
CLUSTER_RESOURCE_GROUP: your-cluster-group
NAMESPACE: default
APP_NAME: angular-frontned
SOURCE_FOLDER: ./
name: Angular Frontend dev AKS
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the dev-deployment branch
push:
branches: [deployment-aks]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Connect to Azure Container Registry (ACR)
- uses: azure/docker-login@v1
with:
login-server: ${{ env.REGISTRY_NAME }}.azurecr.io
username: ${{ secrets.REGISTRY_USERNAME_DEV }}
password: ${{ secrets.REGISTRY_PASSWORD_DEV }}
- uses: actions/setup-node@v1
with:
node-version: '15'
check-latest: true
- id: install-npm
name: install angular
working-directory: ${{ env.SOURCE_FOLDER }}
run: |-
npm install -g @angular/cli
npm install -g yarn
yarn
- id: build
name: Build angular
working-directory: ${{ env.SOURCE_FOLDER }}
run: npm run publish
- name: copy Dockerfile, nginx conf
working-directory: ${{ env.SOURCE_FOLDER }}
run: |-
cp ./Dockerfile ./dist/Dockerfile
cp ./nginx.conf ./dist/nginx.conf
# Container build and push to a Azure Container Registry (ACR)
- id: docker-build-push
name: Docker build and push to container registry
working-directory: ${{ env.SOURCE_FOLDER }}/dist
run: |
docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.APP_NAME }}
docker push ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.APP_NAME }}
# Set the target Azure Kubernetes Service (AKS) cluster.
- uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS_DEV }}'
cluster-name: ${{ env.CLUSTER_NAME }}
resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }}
# restart aks deployment
- id: restart-deployment
run: |
kubectl rollout restart deployment/${{ env.APP_NAME }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment