-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (143 loc) · 5.28 KB
/
terraform-provider-generator.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
---
name: "Terraform: Provider Generator"
on: # yamllint disable-line rule:truthy
push:
# branches:
# - main
env:
CACHE_KEY: "${{ github.repository }}-${{ github.ref }}"
CACHE_PATHS: |
~/.cache/go-build
/go/bin
/home/runner/go/bin/
GO_VERSION: 1.23
OPENAPI_GENERATOR_CONFIG: generator_config.yml
OPENAPI_GENERATOR_INPUT: openapi.yml
OPENAPI_GENERATOR_OUTPUT: provider_code_spec.json
jobs:
install-binaries:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: false
name: install-binaries
runs-on: ubuntu-latest
strategy:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
fail-fast: false
matrix:
tools:
- binary: tfplugingen-framework
repository: "github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework@latest"
- binary: tfplugingen-openapi
repository: "github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest"
timeout-minutes: 5
steps:
# see https://github.com/marketplace/actions/checkout
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 1
# see https://github.com/marketplace/actions/setup-go-environment
- name: Setup Go `v${{ env.GO_VERSION }}`
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
# see https://github.com/actions/cache
- name: Restore Cache
uses: actions/cache@v4
with:
key: "${{ env.CACHE_KEY }}"
path: ${{ env.CACHE_PATHS }}
# see https://github.com/actions/cache
- name: Populate Cache
uses: actions/cache@v4
with:
key: "${{ env.CACHE_KEY }}"
path: ${{ env.CACHE_PATHS }}
- name: Install `${{ matrix.tools.binary }}`
run: |
go \
install \
"${{ matrix.tools.repository }}"
- name: Print `${{ matrix.tools.binary }}` version
run: |
${{ matrix.tools.binary }} \
--version
generate-provider:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: false
name: generate-provider
needs: install-binaries
runs-on: ubuntu-latest
strategy:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
fail-fast: false
matrix:
# TODO: make this a more global setting
targets:
- "./mobility-platform"
timeout-minutes: 5
steps:
# see https://github.com/actions/cache
- name: Restore existing cache
uses: actions/cache@v4
with:
key: "${{ env.CACHE_KEY }}"
path: ${{ env.CACHE_PATHS }}
# TODO:
- name: Render Terraform Provider spec with `tfplugingen-openapi`
run: |
echo tfplugingen-openapi \
generate \
--config "${{ matrix.targets }}${{ env.OPENAPI_GENERATOR_CONFIG }}" \
--output "${{ matrix.targets }}${{ env.OPENAPI_GENERATOR_OUTPUT }}" \
"${{ matrix.targets }}${{ env.OPENAPI_GENERATOR_INPUT }}"
commit-changes:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: false
name: commit-changes
needs: generate-provider
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
# needed for `git-auto-commit-action` to be able to make changes to the generated output file
contents: write
runs-on: ubuntu-latest
strategy:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
fail-fast: false
matrix:
# TODO: make this a more global setting
targets:
- "./mobility-platform"
timeout-minutes: 5
steps:
- name: Add updated Output to Repository
run: |
echo "Add updated Output to Repository"
# # see https://github.com/marketplace/actions/git-auto-commit
# - name: Add updated Output to Repository
# uses: stefanzweifel/git-auto-commit-action@v5
# with:
# commit_author: "GitHub Actions <github-actions[bot]@users.noreply.github.com>"
# commit_message: automated update of rendered provider specification
# commit_options: "--no-verify --signoff"
# commit_user_email: "github-actions[bot]@users.noreply.github.com"
# commit_user_name: "github-actions[bot]"
#
# create_branch: true
#
# disable_globbing: true
#
# file_pattern: "${{ env.OPENAPI_GENERATOR_OUTPUT }}"
# repository: .
# status_options: "--untracked-files=normal"
#
# skip_dirty_check: false
# skip_fetch: false
# skip_checkout: true