Skip to content

copying the template files at the right place (#121) #93

copying the template files at the right place (#121)

copying the template files at the right place (#121) #93

Workflow file for this run

on:
push:
branches:
- main
jobs:
build-and-deploy-to-uat:
environment: uat # Points to the set of environment secrets kept in GitHub secrets
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
steps:
- name: Checkout Github Repository
uses: actions/checkout@v4
- name: Build and test the code
uses: './.github/build-and-test'
- name: Run Snyk security suite
uses: './.github/snyk-scan'
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN}}
- name: Set Spring profile
run: echo "SPRING_PROFILES_ACTIVE=uat" >> $GITHUB_ENV
- uses: './.github/login-to-aws'
env:
ROLE: ${{ secrets.UAT_ECR_ROLE_TO_ASSUME }}
AWS_REGION: ${{ vars.ECR_REGION }}
- name: Login to container repository
uses: aws-actions/amazon-ecr-login@v2
id: login-ecr
- name: Build the docker image and push it to the repository
uses: './.github/build-push-docker-image'
env:
REPOSITORY: ${{ vars.UAT_ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
- name: Generate Kubernetes files from templates
env:
IMAGE_TAG: ${{ github.sha }} # Tags ECR image with commit sha
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ vars.UAT_ECR_REPOSITORY }}
NAMESPACE: ${{ secrets.KUBE_NAMESPACE_UAT }}
ALERT_SEVERITY: laa-get-legal-aid-data-uat
run: |
cat deployments/uat/deployment.tpl | envsubst > deployments/uat/deployment.yml
cat deployments/uat/ingress.tpl | envsubst > deployments/uat/ingress.yml
cat deployments/uat/service.tpl | envsubst > deployments/uat/service.yml
cat deployments/uat/network-policy.tpl | envsubst > deployments/uat/network-policy.yml
cat deployments/uat/service-monitor.tpl | envsubst > deployments/uat/service-monitor.yml
cat deployments/uat/prometheus-rules.tpl | envsubst > deployments/uat/prometheus-rules.yml
- name: Authenticate with Cloud Platform and Deploy
env:
KUBE_NAMESPACE: ${{ secrets.KUBE_NAMESPACE_UAT }}
KUBE_CLUSTER: ${{ secrets.KUBE_CLUSTER_UAT }}
run: |
echo "${{ secrets.KUBE_CERT_UAT }}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
kubectl config set-credentials deploy-user --token=${{ secrets.KUBE_TOKEN_UAT }}
kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=deploy-user --namespace=${KUBE_NAMESPACE}
kubectl config use-context ${KUBE_CLUSTER}
kubectl -n ${KUBE_NAMESPACE} apply -f deployments/uat/