Skip to content

Commit 0eb0164

Browse files
committed
feat: Refactor workflows
Signed-off-by: Steve Hipwell <[email protected]>
1 parent d866b8e commit 0eb0164

16 files changed

+401
-596
lines changed

.github/workflows/add_to_octokit_project.yml renamed to .github/workflows/add-to-octokit-project.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
name: Add PRs and issues to Octokit org project
1+
name: Add PRs & Issues to Octokit Org Project
22

33
on:
44
issues:
55
types: [reopened, opened]
66
pull_request_target:
77
types: [reopened, opened]
88

9+
permissions: read-all
10+
911
jobs:
1012
add-to-project:
11-
name: Add issue to project
13+
name: Add to Project
1214
runs-on: ubuntu-latest
1315
continue-on-error: true
14-
if: ${{ github.repository == 'integrations/terraform-provider-github' }}
16+
defaults:
17+
run:
18+
shell: bash
1519
steps:
16-
- uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e #v1.0.2
20+
- name: Add to project
21+
uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
1722
with:
1823
project-url: https://github.com/orgs/octokit/projects/10
1924
github-token: ${{ secrets.OCTOKITBOT_PROJECT_ACTION_TOKEN }}

.github/workflows/ci.yml renamed to .github/workflows/ci.yaml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,35 @@ name: GitHub Actions CI
22

33
on:
44
push:
5-
branches: [main]
6-
pull_request: {}
5+
branches:
6+
- main
7+
- release-v*
8+
pull_request:
9+
branches:
10+
- main
11+
- release-v*
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
716

817
permissions:
918
contents: read # for actions/checkout
1019

11-
env:
12-
test_stacks_directory: test_tf_stacks
13-
1420
jobs:
1521
ci:
1622
name: Continuous Integration
1723
runs-on: ubuntu-latest
24+
defaults:
25+
run:
26+
shell: bash
1827
env:
1928
GITHUB_TEST_ORGANIZATION: kfcampbell-terraform-provider
2029
steps:
21-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
22-
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
30+
- name: Checkout
31+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
32+
- name: Set-up Go
33+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
2334
with:
2435
go-version-file: go.mod
2536
cache: true
@@ -32,6 +43,11 @@ jobs:
3243
generate-matrix:
3344
name: Generate matrix for test stacks
3445
runs-on: ubuntu-latest
46+
defaults:
47+
run:
48+
shell: bash
49+
env:
50+
TEST_STACKS_DIRECTORY: test-stacks
3551
outputs:
3652
matrix: ${{ steps.set-matrix.outputs.matrix }}
3753
has-tests: ${{ steps.set-matrix.outputs.has-tests }}
@@ -42,7 +58,7 @@ jobs:
4258
- name: Generate matrix
4359
id: set-matrix
4460
run: |
45-
if [ -d "${{ env.test_stacks_directory }}" ]; then
61+
if [ -d "${{ env.TEST_STACKS_DIRECTORY }}" ]; then
4662
# find all directories and validate their names
4763
VALID_TESTS=()
4864
INVALID_TESTS=()
@@ -51,11 +67,11 @@ jobs:
5167
dirname=$(basename "$dir")
5268
# validate that directory name only contains alphanumeric, hyphens, underscores, and dots
5369
if [[ "$dirname" =~ ^[a-zA-Z0-9_.-]+$ ]]; then
54-
VALID_TESTS+=("$dirname")
70+
VALID_TESTS+=("$dir")
5571
else
5672
INVALID_TESTS+=("$dirname")
5773
fi
58-
done < <(find ${{ env.test_stacks_directory }} -mindepth 1 -maxdepth 1 -type d)
74+
done < <(find ${{ env.TEST_STACKS_DIRECTORY }} -mindepth 1 -maxdepth 1 -type d)
5975
6076
# report invalid directory names if any
6177
if [ ${#INVALID_TESTS[@]} -gt 0 ]; then
@@ -75,7 +91,7 @@ jobs:
7591
echo "No valid test directories found"
7692
fi
7793
else
78-
echo "Test directory ${{ env.test_stacks_directory }} does not exist"
94+
echo "Test directory ${{ env.TEST_STACKS_DIRECTORY }} does not exist"
7995
echo "matrix=[]" >> $GITHUB_OUTPUT
8096
echo "has-tests=false" >> $GITHUB_OUTPUT
8197
fi
@@ -85,12 +101,13 @@ jobs:
85101
needs: [ci, generate-matrix]
86102
if: ${{ needs.generate-matrix.outputs.has-tests == 'true' }} # only run if there are some test stacks
87103
runs-on: ubuntu-latest
88-
104+
defaults:
105+
run:
106+
shell: bash
89107
strategy:
90108
fail-fast: false
91109
matrix:
92110
tests: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
93-
94111
steps:
95112
- name: Checkout
96113
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
@@ -129,10 +146,10 @@ jobs:
129146

130147
- name: Terraform init
131148
continue-on-error: true # continue even if init fails
132-
run: terraform -chdir=./${{ env.test_stacks_directory }}/${{ matrix.tests }} init
149+
run: terraform -chdir=${{ matrix.tests }} init
133150

134151
- name: Terraform validate
135-
run: terraform -chdir=./${{ env.test_stacks_directory }}/${{ matrix.tests }} validate
152+
run: terraform -chdir=${{ matrix.tests }} validate
136153

137154
- name: Clean up
138155
run: rm -f ~/.terraformrc terraform-provider-github

.github/workflows/codeql.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: CodeQL
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
# The branches below must be a subset of the branches above
9+
branches: ["main"]
10+
schedule:
11+
- cron: "16 7 * * 5"
12+
13+
concurrency:
14+
group: codeql-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
permissions: read-all
18+
19+
jobs:
20+
analyze:
21+
name: Analyze (${{ matrix.language }})
22+
runs-on: ubuntu-latest
23+
permissions:
24+
actions: read
25+
contents: read
26+
security-events: write
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- language: actions
32+
build-mode: none
33+
queries: security-extended # can be 'default' (use empty for 'default'), 'security-and-quality', 'security-extended'
34+
- language: go
35+
build-mode: manual
36+
queries: "" # will be used 'default' queries
37+
defaults:
38+
run:
39+
shell: bash
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
43+
44+
- name: Set-up Go
45+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
46+
if: matrix.language == 'go'
47+
with:
48+
go-version-file: go.mod
49+
cache: true
50+
51+
- name: Initialize CodeQL
52+
uses: github/codeql-action/init@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v4.31.4
53+
with:
54+
languages: ${{ matrix.language }}
55+
build-mode: ${{ matrix.build-mode }}
56+
queries: ${{ matrix.queries }}
57+
58+
- name: Build Go
59+
if: ${{ matrix.language == 'go' }}
60+
run: go build ./...
61+
62+
- name: Perform CodeQL Analysis
63+
uses: github/codeql-action/analyze@e12f0178983d466f2f6028f5cc7a6d786fd97f4b # v4.31.4
64+
with:
65+
category: "/language:${{matrix.language}}"
66+
67+
check:
68+
name: Check CodeQL Analysis
69+
if: always() && github.event_name == 'pull_request'
70+
needs:
71+
- analyze
72+
runs-on: ubuntu-latest
73+
defaults:
74+
run:
75+
shell: bash
76+
steps:
77+
- name: Check
78+
env:
79+
INPUT_RESULTS: ${{ join(needs.*.result, ' ') }}
80+
run: |
81+
set -euo pipefail
82+
read -a results <<< "${INPUT_RESULTS}"
83+
for result in "${results[@]}"; do
84+
if [[ "${result}" == "failure" ]] || [[ "${result}" == "cancelled" ]]; then
85+
echo "::error::Workflow failed!"
86+
exit 1
87+
fi
88+
done

.github/workflows/codeql.yml

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

.github/workflows/dotcom-acceptance-tests-all.yml

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

0 commit comments

Comments
 (0)