-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (130 loc) · 4.67 KB
/
deploy-production.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Deploy to Production
on:
push:
tags:
- 'release/**'
concurrency:
group: deploy-production
cancel-in-progress: false
permissions:
contents: read
id-token: write
jobs:
build-lambdas:
name: Build Lambda handlers
permissions:
contents: read
uses: ./.github/workflows/build.yml
with:
ref: ${{ github.sha }}
build-cli: true
build-lambdas: true
artifacts-retention-days: 90
aws-auth:
name: Configure AWS Credentials
permissions:
contents: read
id-token: write
uses: ./.github/workflows/aws-auth.yml
with:
aws-region: us-west-2
secrets:
gpg-passphrase: ${{ secrets.PRODUCTION_GPG_PASSPHRASE }}
role-to-assume: ${{ secrets.PRODUCTION_ROLE_ARN }}
tf-plan:
name: Plan Terraform
permissions:
contents: read
needs:
- aws-auth
- build-lambdas
uses: ./.github/workflows/terraform-plan.yml
with:
ref: ${{ github.sha }}
concurrency-group: run_terraform-production
bin-artifacts-key: ${{ needs.build-lambdas.outputs.lambda-artifacts-key }}
bin-artifacts-path: ${{ needs.build-lambdas.outputs.lambda-artifacts-path }}
aws-region: us-west-2
environment-key: production
tf-backend-config-file: production.s3.tfbackend
tf-var-file: production.tfvars
upload-artifacts: true
artifacts-retention-days: 90
secrets:
aws-access-key-id: ${{ needs.aws-auth.outputs.aws-access-key-id }}
aws-secret-access-key: ${{ needs.aws-auth.outputs.aws-secret-access-key }}
aws-session-token: ${{ needs.aws-auth.outputs.aws-session-token }}
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
datadog-app-key: ${{ secrets.DATADOG_APP_KEY }}
gpg-passphrase: ${{ secrets.PRODUCTION_GPG_PASSPHRASE }}
publish-tf-plan:
name: Publish Terraform Plan
permissions:
contents: read
pull-requests: write
if: needs.tf-plan.result != 'skipped' || needs.tf-plan.result != 'cancelled'
needs:
- tf-plan
uses: ./.github/workflows/publish-terraform-plan.yml
with:
write-summary: true
write-comment: false
tf-fmt-outcome: ${{ needs.tf-plan.outputs.fmt-outcome }}
tf-init-outcome: ${{ needs.tf-plan.outputs.init-outcome }}
tf-plan-outcome: ${{ needs.tf-plan.outputs.plan-outcome }}
tf-plan-output: ${{ needs.tf-plan.outputs.plan-output }}
tf-validate-outcome: ${{ needs.tf-plan.outputs.validate-outcome }}
tf-validate-output: ${{ needs.tf-plan.outputs.validate-output }}
tf-apply:
name: Deploy to Production
needs:
- build-lambdas
- aws-auth
- tf-plan
if: needs.tf-plan.outputs.plan-exitcode == 2
uses: ./.github/workflows/terraform-apply.yml
with:
bin-artifacts-key: ${{ needs.build-lambdas.outputs.lambda-artifacts-key }}
bin-artifacts-path: ${{ needs.build-lambdas.outputs.lambda-artifacts-path }}
tf-plan-artifacts-key: ${{ needs.tf-plan.outputs.artifacts-key }}
aws-region: us-west-2
concurrency-group: run_terraform-production
tf-backend-config-file: production.s3.tfbackend
environment-name: production
secrets:
aws-access-key-id: ${{ needs.aws-auth.outputs.aws-access-key-id }}
aws-secret-access-key: ${{ needs.aws-auth.outputs.aws-secret-access-key }}
aws-session-token: ${{ needs.aws-auth.outputs.aws-session-token }}
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
datadog-app-key: ${{ secrets.DATADOG_APP_KEY }}
gpg-passphrase: ${{ secrets.PRODUCTION_GPG_PASSPHRASE }}
update-release:
name: Update release
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- tf-apply
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.ref_name }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get release notes
id: get
continue-on-error: true
run: gh release view $RELEASE_TAG --json body --jq .body > release_notes.md
- name: Add deployment history to release notes
if: always() && steps.get.outcome == 'success'
run: printf "\n- Deployed at $(date --iso-8601=seconds)\n" >> release_notes.md
- name: Update release notes and status
if: always() && steps.get.outcome == 'success'
run: gh release edit $RELEASE_TAG --draft=false --prerelease=false --latest --verify-tag -F release_notes.md