-
Notifications
You must be signed in to change notification settings - Fork 4
93 lines (77 loc) · 2.84 KB
/
deploy-recordprocessor.yml
File metadata and controls
93 lines (77 loc) · 2.84 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Deploy Recordprocessor Batch Processor
on:
workflow_call:
inputs:
environment:
description: "AWS environment (e.g. dev, preprod, prod)"
required: true
type: string
sub_environment:
description: "Sub-environment (e.g. internal-dev, internal-qa)"
required: true
type: string
jobs:
build-and-push-recordprocessor:
name: Build and push recordprocessor image
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.build-and-push.outputs.image_tag }}
env:
AWS_REGION: eu-west-2
steps:
- name: Checkout
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a
with:
role-to-assume: ${{ secrets.AWS_INFRA_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076
- name: Build and push Docker image
id: build-and-push
working-directory: lambdas/recordprocessor
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
SUB_ENVIRONMENT: ${{ inputs.sub_environment }}
run: |
IMAGE_TAG="${GITHUB_SHA}"
REPOSITORY_NAME="imms-${SUB_ENVIRONMENT}-processing-repo"
IMAGE_URI="${ECR_REGISTRY}/${REPOSITORY_NAME}:${IMAGE_TAG}"
docker build -t "${IMAGE_URI}" .
docker push "${IMAGE_URI}"
echo "image_tag=${IMAGE_TAG}" >> "$GITHUB_OUTPUT"
terraform-deploy-recordprocessor:
name: Deploy recordprocessor infrastructure
needs: build-and-push-recordprocessor
runs-on: ubuntu-latest
env:
AWS_REGION: eu-west-2
ENVIRONMENT: ${{ inputs.environment }}
SUB_ENVIRONMENT: ${{ inputs.sub_environment }}
APIGEE_ENVIRONMENT: ${{ inputs.sub_environment }}
TF_VAR_recordprocessor_image_tag: ${{ needs.build-and-push-recordprocessor.outputs.image_tag }}
steps:
- name: Checkout
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a
with:
role-to-assume: ${{ secrets.AWS_INFRA_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- name: Terraform init
working-directory: infrastructure/instance
env:
AWS_PROFILE: ""
run: make init
- name: Terraform plan
working-directory: infrastructure/instance
env:
AWS_PROFILE: ""
run: make plan-ci
- name: Terraform apply
working-directory: infrastructure/instance
env:
AWS_PROFILE: ""
run: make apply-ci