Skip to content

Commit

Permalink
[TM-1448] Try triggering job service build from new action
Browse files Browse the repository at this point in the history
  • Loading branch information
roguenet committed Nov 12, 2024
1 parent 35d9220 commit a4a93e4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 8 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/deploy-service.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Service Deploy
run-name: 'Service Deploy [service: ${{ inputs.service }}, env: ${{ inputs.env }}]'
run-name: 'Service Deploy [service: ${{ env.INPUT_SERVICE }}, env: ${{ env.INPUT_ENV }}]'

on:
workflow_dispatch:
Expand Down Expand Up @@ -27,17 +27,20 @@ permissions:
contents: read

env:
INPUT_ENV: ${{ inputs.env }}
INPUT_SERVICE: ${{ inputs.service }}
INPUT_INDEPENDENT_RUN: true
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-${{ inputs.service }}
ECR_REPOSITORY: terramatch-microservices/${{ inputs.service }}-${{ inputs.env }}
AWS_ROLE_SESSION_NAME: terramatch-microservices-cicd-${{ env.INPUT_SERVICE }}
ECR_REPOSITORY: terramatch-microservices/${{ env.INPUT_SERVICE }}-${{ env.INPUT_ENV }}
ECR_REGISTRY: 603634817705.dkr.ecr.eu-west-1.amazonaws.com
IMAGE_TAG: ${{ github.sha }}

jobs:
deploy-service:
runs-on: ubuntu-latest
environment: ${{ inputs.env }}
environment: ${{ env.INPUT_ENV }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -53,15 +56,20 @@ jobs:
id: AWS
uses: aws-actions/amazon-ecr-login@v1

- name: Build base image
id: build-base-image
if: ${{ env.INPUT_INDEPENDENT_RUN }}
run: |
: # 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 .
- name: Build, tag, and push images to Amazon ECR
id: build-images
run: |
echo "${{ vars.ENV }}" > .env
echo "DB_PASSWORD=\"${{ secrets.DB_PASSWORD }}\"" >> .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 .
SERVICE_IMAGE=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker build --build-arg NODE_ENV=production --build-arg BUILD_FLAG=--prod -f apps/${{ inputs.service }}/Dockerfile -t $SERVICE_IMAGE .
docker build --build-arg NODE_ENV=production --build-arg BUILD_FLAG=--prod -f apps/${{ env.INPUT_SERVICE }}/Dockerfile -t $SERVICE_IMAGE .
docker push $SERVICE_IMAGE
echo "image=$SERVICE_IMAGE"
Expand All @@ -70,5 +78,5 @@ jobs:
run: |
cd cdk/service-stack
npm i
IMAGE_TAG=$IMAGE_TAG TM_SERVICE=${{ inputs.service }} TM_ENV=${{ inputs.env }} npx --yes cdk deploy --require-approval never
IMAGE_TAG=$IMAGE_TAG TM_SERVICE=${{ env.INPUT_SERVICE }} TM_ENV=${{ env.INPUT_ENV }} npx --yes cdk deploy --require-approval never
41 changes: 41 additions & 0 deletions .github/workflows/deploy-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Services Deploy (all)
run-name: 'Services Deploy [env: ${{ inputs.env }}]'

on:
workflow_dispatch:
inputs:
env:
description: 'Deployment target environment'
type: choice
required: true
options:
- dev
- test
- staging
- prod

permissions:
id-token: write
contents: read

jobs:
deploy-service:
runs-on: ubuntu-latest
environment: ${{ inputs.env }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build base image
id: build-base-image
run: |
: # 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 .
job-service:
uses: wri/terramatch-microservices/.github/workflows/deploy-service.yml@task/TM-1448-unified-deployment
with:
env: ${{ inputs.env }}
service: job-service
independent_run: true

0 comments on commit a4a93e4

Please sign in to comment.