Skip to content

Commit 0997e03

Browse files
committed
πŸŽ› [ci] Apply staging change pipeline
1 parent 727c5d2 commit 0997e03

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: "πŸš€ Apply Staging"
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "staging/**"
8+
- "template/**"
9+
- ".github/workflows/apply-staging.yml"
10+
workflow_dispatch:
11+
12+
# Stateless runs must never overlap: each one imports existing buckets into
13+
# a fresh throwaway state, so two racing applies would double-create.
14+
concurrency:
15+
group: terraform-staging
16+
cancel-in-progress: false
17+
18+
permissions:
19+
contents: read
20+
21+
env:
22+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
23+
TF_VAR_cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
24+
TF_IN_AUTOMATION: "true"
25+
# Lets mise query the GitHub releases API without anonymous rate limits
26+
GITHUB_TOKEN: ${{ github.token }}
27+
28+
jobs:
29+
plan:
30+
name: "πŸ— Terraform Plan"
31+
runs-on: ubuntu-latest
32+
defaults:
33+
run:
34+
working-directory: "staging"
35+
steps:
36+
- name: "πŸ›’ Checkout"
37+
uses: actions/checkout@v7
38+
39+
- name: "🐭 Setup mise"
40+
uses: jdx/mise-action@v4
41+
42+
- name: "🎨 Format Check"
43+
working-directory: "."
44+
run: terraform fmt -check -recursive staging template
45+
46+
- name: "βš™οΈ Terraform Init"
47+
run: terraform init -input=false
48+
49+
- name: "βœ… Terraform Validate"
50+
run: terraform validate
51+
52+
- name: "πŸ“₯ Import Existing Buckets"
53+
run: ../scripts/import-resources.sh
54+
55+
- name: "πŸ“‹ Terraform Plan"
56+
run: terraform plan -input=false -out=tfplan
57+
58+
- name: "πŸ“¦ Upload Plan"
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: tfplan
62+
path: |
63+
staging/tfplan
64+
staging/terraform.tfstate
65+
retention-days: 3
66+
if-no-files-found: warn
67+
68+
apply:
69+
name: "πŸš€ Terraform Apply"
70+
needs: plan
71+
if: github.event_name == 'workflow_dispatch'
72+
runs-on: ubuntu-latest
73+
# The environment carries a 24h wait timer (configured in repo settings):
74+
# the job sits in "Waiting" for 24h, and cancelling the run aborts the apply.
75+
environment: "Staging"
76+
defaults:
77+
run:
78+
working-directory: "staging"
79+
steps:
80+
- name: "πŸ›’ Checkout"
81+
uses: actions/checkout@v7
82+
83+
- name: "🐭 Setup mise"
84+
uses: jdx/mise-action@v4
85+
86+
- name: "πŸ“¦ Download Plan"
87+
uses: actions/download-artifact@v4
88+
with:
89+
name: tfplan
90+
path: staging
91+
92+
- name: "βš™οΈ Terraform Init"
93+
run: terraform init -input=false
94+
95+
- name: "πŸš€ Terraform Apply"
96+
run: terraform apply -input=false tfplan

0 commit comments

Comments
Β (0)