forked from cloudposse/github-action-atmos-affected-stacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
107 lines (101 loc) · 3.64 KB
/
action.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
name: "Atmos Affected Stacks Qventus"
description: "A GitHub Action to determine the affected stacks for a given pull request"
author: [email protected]
branding:
icon: "file"
color: "white"
inputs:
default-branch:
description: The default branch to use for the base ref.
required: false
default: ${{ github.event.repository.default_branch }}
head-ref:
description: The head ref to checkout. If not provided, the head default branch is used.
required: false
install-atmos:
description: Whether to install atmos
required: false
default: "true"
atmos-version:
description: The version of atmos to install if install-atmos is true
required: false
default: "latest"
atmos-config-path:
description: The path to the atmos.yaml file
required: false
default: atmos.yaml
atmos-include-spacelift-admin-stacks:
description: Whether to include the Spacelift admin stacks of affected stacks in the output
required: false
default: "false"
terraform-version:
description: The version of terraform to install if install-terraform is true
required: false
default: "latest"
install-jq:
description: Whether to install jq
required: false
default: "false"
jq-version:
description: The version of jq to install if install-jq is true
required: false
default: "1.6"
jq-force:
description: Whether to force the installation of jq
required: false
default: "true"
outputs:
affected:
description: The affected stacks
value: ${{ steps.affected.outputs.affected }}
has-affected-stacks:
description: Whether there are affected stacks
value: ${{ steps.affected.outputs.affected != '[]' }}
matrix:
description: A matrix suitable for use for GitHub Actions of the affected stacks
value: ${{ steps.matrix.outputs.matrix }}
runs:
using: "composite"
steps:
- if: ${{ inputs.install-atmos == 'true' }}
uses: cloudposse/github-action-setup-atmos@v2
with:
atmos-version: ${{ inputs.atmos-version }}
install-wrapper: false
- if: ${{ inputs.install-jq == 'true' }}
uses: dcarbone/[email protected]
with:
version: ${{ inputs.jq-version }}
force: ${{ inputs.jq-force }}
# atmos describe affected requires the main branch of the git repo to be present on disk so it can compare the
# current branch to it to determine the affected stacks. This is different from a file-based git diff in that we
# look at the contents of the stack files to determine if any have changed.
- uses: actions/[email protected]
with:
ref: ${{ inputs.default-branch }}
path: main-branch
fetch-depth: 0
- name: checkout head ref
id: head-ref
shell: bash
run: git checkout ${{ inputs.head-ref }}
working-directory: main-branch
- name: atmos affected stacks
id: affected
shell: bash
env:
ATMOS_CLI_CONFIG_PATH: ${{inputs.atmos-config-path}}
run: |
if [[ "${{ inputs.atmos-include-spacelift-admin-stacks }}" == "true" ]]; then
atmos describe affected --file affected-stacks.json --verbose=true --repo-path "$GITHUB_WORKSPACE/main-branch" --include-spacelift-admin-stacks=true
else
atmos describe affected --file affected-stacks.json --verbose=true --repo-path "$GITHUB_WORKSPACE/main-branch"
fi
affected=$(jq -c '.' < affected-stacks.json)
printf "%s" "affected=$affected" >> $GITHUB_OUTPUT
- name: build matrix
id: matrix
shell: bash
run: |
matrix=$(jq -c '{include:[.[]]}' < affected-stacks.json)
echo "matrix=$matrix" >> $GITHUB_OUTPUT