Merge pull request #820 from makerdao/TECH-3595-prod #74
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
name: Build Prod Angular - Frontend | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- "frontend/**" | |
- ".github/workflows/angular-prod.yml" | |
- "helm/prod/frontend*" | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
REGION: eu-central-1 | |
CLUSTER_NAME: maker-prod-eu | |
SERVICE_NAME: mips-frontend | |
AWS_ECR_NAME: mips-frontend-prod | |
ENVIRONMENT_TAG: prod | |
HELM_FILE: helm/prod/frontend.yaml | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.GA_OIDC_EKS_PROD }} | |
role-session-name: AngularProdMips | |
aws-region: ${{ env.REGION }} | |
- name: Login to AWS ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Extract commit hash | |
id: vars | |
if: ${{ !contains(github.event.head_commit.message , '[skip build]') }} | |
shell: bash | |
run: | | |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
- name: Build, tag, and push image to ECR | |
id: build-image | |
if: ${{ !contains(github.event.head_commit.message , '[skip build]') }} | |
working-directory: frontend | |
env: | |
SHA_TAG: ${{ steps.vars.outputs.sha_short }} | |
LATEST_TAG: latest | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
run: | | |
# Build Docker containers and push them to ECR ${{ env.AWS_ECR_NAME }} | |
docker pull $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG || true | |
docker build -t $AWS_ECR_NAME \ | |
-t $ECR_REGISTRY/$AWS_ECR_NAME:$SHA_TAG \ | |
-t $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG \ | |
-t $ECR_REGISTRY/$AWS_ECR_NAME:$ENVIRONMENT_TAG \ | |
--build-arg ENV=prod \ | |
-f Dockerfile \ | |
. | |
docker push $ECR_REGISTRY/$AWS_ECR_NAME --all-tags | |
- name: Deploying Service to Kubernetes with Helm | |
id: deploy | |
if: ${{ !contains(github.event.head_commit.message , '[skip deploy]') }} | |
uses: bitovi/github-actions-deploy-eks-helm@v1.2.8 | |
with: | |
values: image.repository=${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }},image.tag=${{ steps.vars.outputs.sha_short }} | |
cluster-name: ${{ env.CLUSTER_NAME }} | |
config-files: ${{ env.HELM_FILE }} | |
chart-path: techops-services/common | |
namespace: mips | |
timeout: 5m0s | |
name: ${{ env.SERVICE_NAME }} | |
chart-repository: https://techops-services.github.io/helm-charts | |
version: 0.0.31 | |
atomic: true |