-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (64 loc) · 2.3 KB
/
deploy-service.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Service Deploy
run-name: 'Service Deploy [service: ${{ inputs.service }}, env: ${{ inputs.env }}]'
on:
workflow_dispatch:
inputs:
service:
description: 'Service to deploy'
type: choice
required: true
options:
- user-service
- job-service
env:
description: 'Deployment target environment'
type: choice
required: true
options:
- dev
- test
- staging
- prod
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-${{ inputs.service }}
ECR_REPOSITORY: terramatch-microservices/${{ inputs.service }}-${{ inputs.env }}
ECR_REGISTRY: 603634817705.dkr.ecr.eu-west-1.amazonaws.com
IMAGE_TAG: ${{ github.sha }}
jobs:
main:
runs-on: ubuntu-latest
environment: ${{ inputs.env }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/[email protected]
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 AWS
id: AWS
uses: aws-actions/amazon-ecr-login@v1
- 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 push $SERVICE_IMAGE
echo "image=$SERVICE_IMAGE"
- name: Launch new task definition
id: launch
run: |
cd service-stack
npm i
IMAGE_TAG=$IMAGE_TAG TM_SERVICE=${{ inputs.service }} TM_ENV=${{ inputs.env }} npx --yes cdk deploy --require-approval never