-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (150 loc) · 4.07 KB
/
test-and-release.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
name: Test & Release
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
actions: read
contents: write
statuses: read
env:
TF_VAR_github_app_id: ${{ secrets.GH_APP_ID }}
TF_VAR_github_app_install_id: ${{ secrets.GH_APP_INSTALL_ID }}
TF_VAR_github_app_private_key: ${{ secrets.GH_APP_KEY }}
TF_VAR_labels: '["test", "${{ github.run_id }}"]'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
directory:
- "."
- "examples/full"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Lint Example
uses: "infinite-automations/tflint-all-in-one@v1.0.0"
with:
directory: ${{ matrix.directory }}
update-docs:
name: Update Docs
needs:
- lint
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-docs
cancel-in-progress: false
outputs:
changed: ${{ steps.terraform-docs.outputs.num_changed > 0 }}
steps:
- name: Checkout
uses: actions/checkout@v4
if: ${{ github.event_name == 'push' }}
- name: Checkout
uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Render terraform docs inside the README.md
id: terraform-docs
uses: terraform-docs/gh-actions@v1.0.0
with:
working-dir: .,examples/full
output-file: README.md
output-method: inject
git-push: ${{ github.event_name == 'pull_request' }}
git-commit-message: "docs(terraform): update README.md"
- name: Cache Docs
if: ${{ github.event_name == 'push' }}
uses: actions/cache@v3
with:
path: |
README.md
examples/full/README.md
key: ${{ runner.os }}-docs-${{ github.sha }}
setup-runner:
name: Setup Runner
needs:
- lint
- update-docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.5.0
with:
config: "~/.kube/config"
wait: "120s"
- name: Create Runners
uses: infinite-automations/terraform-all-in-one@v1.2.0
id: apply-example
with:
directory: "examples/full"
apply: true
destroy: false
- name: Wait For Test
uses: NathanFirmo/wait-for-other-job@v1.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
job: "test-runner"
- name: Destroy Runners
uses: infinite-automations/terraform-all-in-one@v1.2.0
with:
directory: "examples/full"
apply: false
destroy: true
test-runner:
name: Run Test Job
needs:
- lint
- update-docs
runs-on:
- self-hosted
- test
- ${{ github.run_id }}
strategy:
matrix:
image:
- alpine:latest
- ubuntu:latest
- debian:latest
container:
image: ${{ matrix.image }}
steps:
- name: Print Environment Information
run: |
echo "Operating System: $OSTYPE"
echo "Hostname: $(hostname)"
echo "CPU Architecture: $(uname -m)"
echo "Kernel Version: $(uname -r)"
echo
cat /etc/os-release
release:
name: Release
needs:
- update-docs
- test-runner
concurrency:
group: ${{ github.ref }}-release
cancel-in-progress: false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore Cached Docs
if: ${{ github.event_name == 'push' }}
uses: actions/cache@v3
with:
path: README.md
key: ${{ runner.os }}-docs-${{ github.sha }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: ${{ github.event_name == 'pull_request' }}
ci: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}