Repository navigation
Expand file tree
/
Copy pathplan-apply.yml
More file actions
100 lines (90 loc) · 3.38 KB
/
Copy pathplan-apply.yml
File metadata and controls
100 lines (90 loc) · 3.38 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
# Example consumer workflow for zeroconfigio/github-action-iac-cicd.
#
# Plans on every pull request (posts/updates a sticky PR comment) and applies
# on merge to main, gated behind a GitHub Environment that requires a manual
# reviewer approval, iac-cicd itself does not gate applies, that's a property
# of the job it runs inside, see the "production" environment below.
#
# Required repo secrets: R2_ACCOUNT_ID, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_BUCKET.
# Required repo setup: Settings -> Environments -> "production" -> add required reviewers.
#
# This example uses the default backend (Cloudflare R2). For AWS S3 with
# static keys, add `backend: s3` and `region: <region>` to both `with:`
# blocks and swap the R2 secrets for AWS ones, see the README's Quickstart
# for the full diff. For AWS S3 with OIDC (no long-lived keys at all), see
# the commented-out alternate `with:` and `permissions:` blocks below each
# job's active `with:` block, and the README's "OIDC for AWS S3" section.
name: iac
on:
pull_request:
paths:
- "**/*.tf"
- "**/*.tfvars"
push:
branches: [main]
paths:
- "**/*.tf"
- "**/*.tfvars"
permissions: {}
concurrency:
group: iac-${{ github.ref }}
cancel-in-progress: false
jobs:
plan:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: zeroconfigio/github-action-iac-cicd@v1
with:
account-id: ${{ secrets.R2_ACCOUNT_ID }}
access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
bucket: ${{ secrets.R2_BUCKET }}
# AWS S3 with OIDC, alternate to the `with:` block above. Needs
# `id-token: write` added to this job's `permissions:` above (not
# shown active here so this file keeps running against R2). No
# access-key-id/secret-access-key: the role is assumed directly.
#
# permissions:
# contents: read
# pull-requests: write
# id-token: write
#
# - uses: zeroconfigio/github-action-iac-cicd@v1
# with:
# backend: s3
# region: us-east-1
# aws-role-arn: arn:aws:iam::123456789012:role/iac-cicd-deploy
# bucket: ${{ secrets.AWS_BUCKET }}
apply:
if: github.event_name == 'push'
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: zeroconfigio/github-action-iac-cicd@v1
with:
account-id: ${{ secrets.R2_ACCOUNT_ID }}
access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
bucket: ${{ secrets.R2_BUCKET }}
# AWS S3 with OIDC, same idea as the plan job above: add
# `id-token: write` to this job's `permissions:` too, apply assumes
# the role independently of the plan run.
#
# permissions:
# contents: read
# id-token: write
#
# - uses: zeroconfigio/github-action-iac-cicd@v1
# with:
# backend: s3
# region: us-east-1
# aws-role-arn: arn:aws:iam::123456789012:role/iac-cicd-deploy
# bucket: ${{ secrets.AWS_BUCKET }}