-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (80 loc) Β· 2.39 KB
/
Copy pathapply-staging.yml
File metadata and controls
97 lines (80 loc) Β· 2.39 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
name: "π Apply Staging"
on:
push:
branches:
- "develop"
paths:
- "staging/**"
- "template/**"
- ".github/workflows/apply-staging.yml"
workflow_dispatch:
# Stateless runs must never overlap: each one imports existing buckets into
# a fresh throwaway state, so two racing applies would double-create.
concurrency:
group: terraform-staging
cancel-in-progress: false
permissions:
contents: read
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
TF_VAR_cloudflare_account_id: ${{ secrets.TF_VAR_CLOUDFLARE_ACCOUNT_ID }}
TF_IN_AUTOMATION: "true"
# Lets mise query the GitHub releases API without anonymous rate limits
GITHUB_TOKEN: ${{ github.token }}
jobs:
plan:
name: "π Terraform Plan"
runs-on: ubuntu-latest
environment: "Staging Plan"
defaults:
run:
working-directory: "staging"
steps:
- name: "π Checkout"
uses: actions/checkout@v7
- name: "π Setup mise"
uses: jdx/mise-action@v4
- name: "π¨ Format Check"
working-directory: "."
run: terraform fmt -check -recursive staging template
- name: "βοΈ Terraform Init"
run: terraform init -input=false
- name: "β
Terraform Validate"
run: terraform validate
- name: "π₯ Import Existing Buckets"
working-directory: "."
run: ./scripts/import-resources.sh
- name: "π Terraform Plan"
run: terraform plan -input=false -out=tfplan
- name: "π¦ Upload Plan"
uses: actions/upload-artifact@v4
with:
name: tfplan
path: |
staging/tfplan
staging/terraform.tfstate
retention-days: 3
if-no-files-found: warn
apply:
name: "π Terraform Apply"
needs: plan
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
environment: "Staging"
defaults:
run:
working-directory: "staging"
steps:
- name: "π Checkout"
uses: actions/checkout@v7
- name: "π Setup mise"
uses: jdx/mise-action@v4
- name: "π¦ Download Plan"
uses: actions/download-artifact@v4
with:
name: tfplan
path: staging
- name: "βοΈ Terraform Init"
run: terraform init -input=false
- name: "π Terraform Apply"
run: terraform apply -input=false tfplan