-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
89 lines (80 loc) · 2.76 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
name: cdktf-synth
description: Synthesize CDKTF stacks in order to deploy infrastructure as code. This project is for demonstration purposes only.
inputs:
github_token:
description: GITHUB_TOKEN to use GitHub API. Simply specify `secrets.GITHUB_TOKEN`. This is required if you wish to save assets.
job_name:
description: jobs.<job-id>.name of this workflow job. This is required if you wish to save assets.
ref:
description: Branch/Commit/Tag to use
default: main
type: string
terraform_version:
description: The version of Terraform to use
default: 1.8.0
required: false
working_directory:
description: Working directory path that contains your cdktf code.
default: ./
required: false
output:
default: cdktf.out
description: Output directory for the synthesized Terraform config
type: string
save:
default: false
description: When set to true, save the generated files to a GitHub Artifact.
type: boolean
outputs:
stacks:
description: JSON array of strings, containing the names of the CDKTF stacks that were synthesized.
value: ${{ steps.synth.outputs.stacks }}
job_id:
description: ID of this job
value: ${{ steps.jobid_action.outputs.job_id }}
runs:
using: composite
steps:
- id: jobid_action
if: ${{ inputs.save == 'true' }}
uses: Tiryoh/gha-jobid-action@v1
with:
github_token: ${{ inputs.GITHUB_TOKEN }}
job_name: ${{ inputs.job_name }}
per_page: 100
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ inputs.terraform_version }}
- uses: actions/checkout@v4
id: checkout
with:
fetch-depth: 0
ref: ${{ inputs.ref }}
- name: Load Configuration
id: configurations
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
echo "node_version=$(cat .nvmrc)" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v4
with:
node-version: ${{ steps.configurations.outputs.node_version }}
cache: npm
cache-dependency-path: ${{ inputs.working_directory }}/package-lock.json
- name: Install Node Dependencies
shell: bash
working-directory: ${{ inputs.working_directory }}
run: npm ci
- name: Synthesize Stacks
id: synth
shell: bash
working-directory: ${{ inputs.working_directory }}
run: |
npx cdktf synth
echo "stacks=$(jq --compact-output --null-input '$ARGS.positional' --args -- $(ls cdktf.out/stacks))" >> $GITHUB_OUTPUT
- name: Save Assets
if: ${{ inputs.save == 'true' }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.jobid_action.outputs.job_id }}
path: ${{ inputs.working_directory }}/${{ inputs.output }}