Skip to content

Commit ee99cba

Browse files
♻️ DEV-3458: Quickstart TLC (#794)
2 parents bfbc5c6 + be6bde5 commit ee99cba

15 files changed

Lines changed: 516 additions & 205 deletions

examples/snippets/.github/workflows/atmos-components-updater.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch: {}
55

66
schedule:
7-
- cron: 0 8 * * *
7+
- cron: "0 8 * * *"
88

99
jobs:
1010
update:

examples/snippets/.github/workflows/atmos-pro-terraform-apply.yaml

Lines changed: 0 additions & 63 deletions
This file was deleted.

examples/snippets/.github/workflows/atmos-pro-terraform-plan.yaml

Lines changed: 0 additions & 55 deletions
This file was deleted.

examples/snippets/.github/workflows/atmos-pro.yaml

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 👽 Atmos Terraform Apply Matrix (Reusable)
2+
run-name: 👽 Atmos Terraform Apply Matrix (Reusable)
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
stacks:
8+
description: "Stacks"
9+
required: true
10+
type: string
11+
sha:
12+
description: "Commit SHA to apply. Default: github.sha"
13+
type: string
14+
required: false
15+
default: "${{ github.event.pull_request.head.sha }}"
16+
atmos-version:
17+
description: The version of atmos to install
18+
required: false
19+
default: ">= 1.63.0"
20+
type: string
21+
atmos-config-path:
22+
description: The path to the atmos.yaml file
23+
required: true
24+
type: string
25+
26+
permissions:
27+
id-token: write # This is required for requesting the JWT
28+
contents: read # This is required for actions/checkout
29+
30+
jobs:
31+
atmos-apply:
32+
if: ${{ inputs.stacks != '{include:[]}' }}
33+
name: ${{ matrix.stack_slug }}
34+
runs-on:
35+
- "runs-on=${{ github.run_id }}"
36+
- "runner=terraform"
37+
- "tag=${{ inputs.component }}-${{ inputs.stack }}"
38+
- "private=false"
39+
strategy:
40+
max-parallel: 10
41+
fail-fast: false # Don't fail fast to avoid locking TF State
42+
matrix: ${{ fromJson(inputs.stacks) }}
43+
## Avoid running the same stack in parallel mode (from different workflows)
44+
concurrency:
45+
group: ${{ matrix.stack_slug }}
46+
cancel-in-progress: false
47+
steps:
48+
- uses: unfor19/install-aws-cli-action@v1
49+
50+
- name: Apply Atmos Component
51+
uses: cloudposse/github-action-atmos-terraform-apply@v2
52+
with:
53+
component: ${{ matrix.component }}
54+
stack: ${{ matrix.stack }}
55+
sha: ${{ inputs.sha }}
56+
atmos-version: ${{ inputs.atmos-version }}
57+
atmos-config-path: ${{ inputs.atmos-config-path }}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: 👽 Atmos Terraform Apply
2+
run-name: 👽 Atmos Terraform Apply
3+
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
permissions:
11+
id-token: write
12+
contents: read
13+
issues: write
14+
pull-requests: write
15+
16+
jobs:
17+
pr:
18+
name: PR Context
19+
runs-on:
20+
- "self-hosted"
21+
- "amd64"
22+
- "common"
23+
steps:
24+
- uses: cloudposse-github-actions/get-pr@v2
25+
id: pr
26+
27+
outputs:
28+
base: ${{ fromJSON(steps.pr.outputs.json).base.sha }}
29+
head: ${{ fromJSON(steps.pr.outputs.json).head.sha }}
30+
auto-apply: ${{ contains( fromJSON(steps.pr.outputs.json).labels.*.name, 'auto-apply') }}
31+
no-apply: ${{ contains( fromJSON(steps.pr.outputs.json).labels.*.name, 'no-apply') }}
32+
33+
atmos-affected:
34+
name: Determine Affected Stacks
35+
if: needs.pr.outputs.no-apply == 'false'
36+
needs: ["pr"]
37+
runs-on:
38+
- "runs-on=${{ github.run_id }}"
39+
- "runner=terraform"
40+
- "tag=${{ inputs.component }}-${{ inputs.stack }}"
41+
- "private=false"
42+
steps:
43+
- id: affected
44+
uses: cloudposse/github-action-atmos-affected-stacks@v4
45+
with:
46+
base-ref: ${{ needs.pr.outputs.base }}
47+
head-ref: ${{ needs.pr.outputs.head }}
48+
atmos-version: ${{ vars.ATMOS_VERSION }}
49+
atmos-config-path: ${{ vars.ATMOS_CONFIG_PATH }}
50+
outputs:
51+
stacks: ${{ steps.affected.outputs.matrix }}
52+
has-affected-stacks: ${{ steps.affected.outputs.has-affected-stacks }}
53+
54+
plan-atmos-components:
55+
needs: ["atmos-affected", "pr"]
56+
if: |
57+
needs.atmos-affected.outputs.has-affected-stacks == 'true' && needs.pr.outputs.auto-apply != 'true'
58+
name: Validate plan (${{ matrix.name }})
59+
uses: ./.github/workflows/atmos-terraform-plan-matrix.yaml
60+
strategy:
61+
matrix: ${{ fromJson(needs.atmos-affected.outputs.stacks) }}
62+
max-parallel: 1 # This is important to avoid ddos GHA API
63+
fail-fast: false # Don't fail fast to avoid locking TF State
64+
with:
65+
stacks: ${{ matrix.items }}
66+
drift-detection-mode-enabled: "true"
67+
continue-on-error: 'true'
68+
atmos-version: ${{ vars.ATMOS_VERSION }}
69+
atmos-config-path: ${{ vars.ATMOS_CONFIG_PATH }}
70+
sha: ${{ needs.pr.outputs.head }}
71+
secrets: inherit
72+
73+
drift-detection:
74+
needs: ["atmos-affected", "plan-atmos-components", "pr"]
75+
if: |
76+
always() && needs.atmos-affected.outputs.has-affected-stacks == 'true' && needs.pr.outputs.auto-apply != 'true'
77+
name: Reconcile issues
78+
runs-on:
79+
- "self-hosted"
80+
- "amd64"
81+
- "common"
82+
steps:
83+
- name: Drift Detection
84+
uses: cloudposse/github-action-atmos-terraform-drift-detection@v2
85+
with:
86+
max-opened-issues: '-1'
87+
process-all: 'false'
88+
89+
auto-apply:
90+
needs: ["atmos-affected", "pr"]
91+
if: |
92+
needs.atmos-affected.outputs.has-affected-stacks == 'true' && needs.pr.outputs.auto-apply == 'true'
93+
name: Apply (${{ matrix.name }})
94+
uses: ./.github/workflows/atmos-terraform-apply-matrix.yaml
95+
strategy:
96+
max-parallel: 1
97+
fail-fast: false # Don't fail fast to avoid locking TF State
98+
matrix: ${{ fromJson(needs.atmos-affected.outputs.stacks) }}
99+
with:
100+
stacks: ${{ matrix.items }}
101+
sha: ${{ needs.pr.outputs.head }}
102+
atmos-version: ${{ vars.ATMOS_VERSION }}
103+
atmos-config-path: ${{ vars.ATMOS_CONFIG_PATH }}
104+
secrets: inherit

0 commit comments

Comments
 (0)