User Service Deploy #9
Workflow file for this run
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: User Service Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
env: | |
description: 'Deployment target environment' | |
type: choice | |
required: true | |
options: | |
- dev | |
- test | |
- staging | |
- production | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
AWS_REGION: eu-west-1 | |
AWS_ROLE_TO_ASSUME: arn:aws:iam::603634817705:role/terramatch-microservices-github-actions | |
AWS_ROLE_SESSION_NAME: terramatch-microservices-cicd | |
ECR_REPOSITORY: terramatch-microservices/user-service-${{ inputs.env }} | |
ECR_REGISTRY: 603634817705.dkr.ecr.eu-west-1.amazonaws.com | |
IMAGE_TAG: ${{ github.sha }} | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4.0.2 | |
with: | |
role-to-assume: ${{ env.AWS_ROLE_TO_ASSUME }} | |
role-session-name: ${{ env.AWS_ROLE_SESSION_NAME }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: AWS | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push images to Amazon ECR | |
id: build-images | |
run: | | |
echo "${{ secrets[format('{0}_ENV', inputs.env)] }}" > .env | |
: # Don't build the base image with NODE_ENV because it'll limit the packages that are installed | |
docker build -t terramatch-microservices-base:nx-base . | |
USER_SERVICE_IMAGE=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
docker build --build-arg NODE_ENV=production --build-arg BUILD_FLAG=--prod -f apps/user-service/Dockerfile -t $USER_SERVICE_IMAGE . | |
docker push $USER_SERVICE_IMAGE | |
echo "image=$USER_SERVICE_IMAGE" | |
- name: Launch new task definition | |
id: launch | |
run: | | |
cd apps/user-service/stack | |
npm i | |
IMAGE_TAG=$IMAGE_TAG TM_ENV=${{ inputs.env }} npx --yes cdk deploy --require-approval never | |