-
Notifications
You must be signed in to change notification settings - Fork 3
106 lines (90 loc) · 3.17 KB
/
deploy.yml
File metadata and controls
106 lines (90 loc) · 3.17 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
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Build and Deploy
on:
workflow_dispatch:
concurrency:
group: build-deploy
cancel-in-progress: true
permissions:
contents: read
actions: read
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
packages: write
attestations: write
security-events: write
env:
REGISTRY: "${{ vars.REGISTRY }}"
ROLE_FOR_OIDC: "${{ secrets.ROLE_FOR_OIDC }}"
ROLE_TO_ASSUME: "${{ secrets.ROLE_TO_ASSUME }}"
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Prepare pre-requisites
uses: ./.github/actions/prepare
- name: Write config/config.json
env:
CONFIG_JSON_FILE: ${{ vars.CONFIG_JSON_FILE }}
run: |
printf '%s' "$CONFIG_JSON_FILE" > config/config.json
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
with:
platforms: 'amd64'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2
- name: Set up AWS credentials via OIDC and role chaining
uses: ./.github/actions/oidc
with:
role-for-oidc: ${{ env.ROLE_FOR_OIDC }}
role-to-assume: ${{ env.ROLE_TO_ASSUME }}
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
- name: Build and push Docker image
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
id: push
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ env.REGISTRY }}:latest
${{ env.REGISTRY }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
runs-on: ubuntu-latest
needs: build-and-push
env:
ROLE_FOR_OIDC: "${{ secrets.ROLE_FOR_OIDC }}"
ROLE_TO_ASSUME: "${{ secrets.ROLE_TO_ASSUME }}"
ECS_CLUSTER: ${{ vars.ECS_CLUSTER }}
ECS_SERVICE: ${{ vars.ECS_SERVICE }}
AWS_REGION: ${{ vars.AWS_REGION }}
permissions:
contents: read
id-token: write
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up AWS credentials via OIDC and role chaining
uses: ./.github/actions/oidc
with:
role-for-oidc: ${{ env.ROLE_FOR_OIDC }}
role-to-assume: ${{ env.ROLE_TO_ASSUME }}
- name: AWS ECS force new deployment
run: |
aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment --region $AWS_REGION