Skip to content

Commit 4a5fcf5

Browse files
committed
feat: Refactor workflows
Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
1 parent d866b8e commit 4a5fcf5

14 files changed

+236
-132
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: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@ 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*
712

813
permissions:
914
contents: read # for actions/checkout
1015

11-
env:
12-
test_stacks_directory: test_tf_stacks
13-
1416
jobs:
1517
ci:
1618
name: Continuous Integration
1719
runs-on: ubuntu-latest
20+
defaults:
21+
run:
22+
shell: bash
1823
env:
1924
GITHUB_TEST_ORGANIZATION: kfcampbell-terraform-provider
2025
steps:
21-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
22-
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
26+
- name: Checkout
27+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
28+
- name: Set-up Go
29+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
2330
with:
2431
go-version-file: go.mod
2532
cache: true
@@ -32,6 +39,11 @@ jobs:
3239
generate-matrix:
3340
name: Generate matrix for test stacks
3441
runs-on: ubuntu-latest
42+
defaults:
43+
run:
44+
shell: bash
45+
env:
46+
TEST_STACKS_DIRECTORY: test-stacks
3547
outputs:
3648
matrix: ${{ steps.set-matrix.outputs.matrix }}
3749
has-tests: ${{ steps.set-matrix.outputs.has-tests }}
@@ -42,7 +54,7 @@ jobs:
4254
- name: Generate matrix
4355
id: set-matrix
4456
run: |
45-
if [ -d "${{ env.test_stacks_directory }}" ]; then
57+
if [ -d "${{ env.TEST_STACKS_DIRECTORY }}" ]; then
4658
# find all directories and validate their names
4759
VALID_TESTS=()
4860
INVALID_TESTS=()
@@ -51,11 +63,11 @@ jobs:
5163
dirname=$(basename "$dir")
5264
# validate that directory name only contains alphanumeric, hyphens, underscores, and dots
5365
if [[ "$dirname" =~ ^[a-zA-Z0-9_.-]+$ ]]; then
54-
VALID_TESTS+=("$dirname")
66+
VALID_TESTS+=("$dir")
5567
else
5668
INVALID_TESTS+=("$dirname")
5769
fi
58-
done < <(find ${{ env.test_stacks_directory }} -mindepth 1 -maxdepth 1 -type d)
70+
done < <(find ${{ env.TEST_STACKS_DIRECTORY }} -mindepth 1 -maxdepth 1 -type d)
5971
6072
# report invalid directory names if any
6173
if [ ${#INVALID_TESTS[@]} -gt 0 ]; then
@@ -75,7 +87,7 @@ jobs:
7587
echo "No valid test directories found"
7688
fi
7789
else
78-
echo "Test directory ${{ env.test_stacks_directory }} does not exist"
90+
echo "Test directory ${{ env.TEST_STACKS_DIRECTORY }} does not exist"
7991
echo "matrix=[]" >> $GITHUB_OUTPUT
8092
echo "has-tests=false" >> $GITHUB_OUTPUT
8193
fi
@@ -85,12 +97,13 @@ jobs:
8597
needs: [ci, generate-matrix]
8698
if: ${{ needs.generate-matrix.outputs.has-tests == 'true' }} # only run if there are some test stacks
8799
runs-on: ubuntu-latest
88-
100+
defaults:
101+
run:
102+
shell: bash
89103
strategy:
90104
fail-fast: false
91105
matrix:
92106
tests: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
93-
94107
steps:
95108
- name: Checkout
96109
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
@@ -129,10 +142,10 @@ jobs:
129142

130143
- name: Terraform init
131144
continue-on-error: true # continue even if init fails
132-
run: terraform -chdir=./${{ env.test_stacks_directory }}/${{ matrix.tests }} init
145+
run: terraform -chdir=${{ matrix.tests }} init
133146

134147
- name: Terraform validate
135-
run: terraform -chdir=./${{ env.test_stacks_directory }}/${{ matrix.tests }} validate
148+
run: terraform -chdir=${{ matrix.tests }} validate
136149

137150
- name: Clean up
138151
run: rm -f ~/.terraformrc terraform-provider-github

.github/workflows/codeql.yaml

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

.github/workflows/codeql.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
name: Issue/PR response
2-
permissions:
3-
issues: write
4-
pull-requests: write
1+
name: Issue/PR Response
2+
53
on:
64
issues:
75
types:
86
- opened
97
pull_request_target:
108
types:
119
- opened
10+
11+
permissions: read-all
12+
1213
jobs:
13-
respond-to-issue:
14-
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' &&
15-
github.actor != 'githubactions[bot]' && github.actor != 'octokitbot' &&
16-
github.repository == 'integrations/terraform-provider-github' }}
14+
respond:
15+
name: Respond to Issue or PR
16+
if: github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' && github.actor != 'githubactions[bot]' && github.actor != 'octokitbot' && github.repository == 'integrations/terraform-provider-github'
1717
runs-on: ubuntu-latest
18+
permissions:
19+
issues: write
20+
pull-requests: write
21+
defaults:
22+
run:
23+
shell: bash
1824
steps:
19-
- name: Determine issue or PR number
20-
id: extract
21-
run: echo "NUMBER=${{ github.event.issue.number || github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
22-
23-
- name: Respond to issue or PR
25+
- name: Comment
2426
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
2527
with:
26-
issue-number: ${{ steps.extract.outputs.NUMBER }}
28+
issue-number: ${{ github.event.issue.number || github.event.pull_request.number }}
2729
body: >
2830
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday!
29-
We have a [process in place](https://github.com/octokit/.github/blob/main/community/prioritization_response.md#overview) for prioritizing and responding to your input.
31+
We have a [process in place](https://github.com/octokit/.github/blob/main/community/prioritization_response.md#overview) for prioritizing and responding to your input.
3032
Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with `Status: Up for grabs`.
3133
You & others like you are the reason all of this works! So thank you & happy coding! 🚀

0 commit comments

Comments
 (0)