-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (144 loc) · 4.67 KB
/
pull-request.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Pull Request
on:
pull_request:
branches: [ master ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
actions: read
strategy:
matrix:
node: [ '20.x' ]
os: [ ubuntu-latest ]
env:
HUSKY: 0 # disables husky hooks
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Configure AWS Actions Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::914054469264:role/github-actions-admin-dev
aws-region: us-east-2
- name: Configure AWS Terraform Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::914054469264:role/terraform-admin
aws-region: us-east-2
role-chaining: true
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install deps (with cache)
uses: bahmutov/npm-install@v1
with:
install-command: yarn --immutable --no-progress --ignore-scripts
- id: read-package-json
name: Read package.json
run: |
content=`cat package.json`
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "::set-output name=packageJson::$content"got
- name: Verify
run: make verify
env:
SKIP_INSTALL: 1 # install with cache was done already
terraform-format-validate:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::914054469264:role/github-actions-admin-dev
aws-region: us-east-2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::914054469264:role/terraform-admin
aws-region: us-east-2
role-chaining: true
- name: Terraform fmt
id: fmt
run: terraform fmt -check -diff
working-directory: terraform/
continue-on-error: false
- name: Terraform init
id: init
run: terraform init -backend-config=dev.tfbackend
working-directory: terraform/
continue-on-error: false
env:
TF_VAR_env: dev
TF_VAR_r2_access_key: ${{secrets.R2_ACCESS_KEY}}
TF_VAR_r2_secret_key: ${{secrets.R2_SECRET_KEY}}
- name: Terraform validate
id: validate
run: terraform validate
working-directory: terraform/
continue-on-error: false
env:
TF_VAR_env: dev
TF_VAR_r2_access_key: ${{secrets.R2_ACCESS_KEY}}
TF_VAR_r2_secret_key: ${{secrets.R2_SECRET_KEY}}
terraform-plan:
runs-on: ubuntu-latest
needs:
- terraform-format-validate
permissions:
id-token: write
contents: read
strategy:
fail-fast: true
matrix:
env: [dev, prod]
include:
- env: dev
account_id: "914054469264"
- env: prod
account_id: "469828239459"
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{matrix.account_id}}:role/github-actions-admin-${{matrix.env}}
aws-region: us-east-2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{matrix.account_id}}:role/terraform-admin
aws-region: us-east-2
role-chaining: true
- name: Terraform init
id: init
run: terraform init -backend-config=${{matrix.env}}.tfbackend
working-directory: terraform/
continue-on-error: false
- name: Terraform plan dev
id: plan
run: terraform plan
working-directory: terraform/
continue-on-error: false
env:
TF_VAR_env: ${{matrix.env}}
TF_VAR_r2_access_key: ${{secrets.R2_ACCESS_KEY}}
TF_VAR_r2_secret_key: ${{secrets.R2_SECRET_KEY}}