Skip to content

Commit 52fa947

Browse files
chore: update global workflows (#231)
Co-authored-by: ReenigneArcher <[email protected]>
1 parent 3cbd8de commit 52fa947

File tree

6 files changed

+91
-46
lines changed

6 files changed

+91
-46
lines changed

.github/workflows/ci.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
name: Jekyll CI
3+
permissions:
4+
contents: read
35

46
on:
57
pull_request:
@@ -20,16 +22,18 @@ concurrency:
2022
jobs:
2123
call-jekyll-build:
2224
uses: ./.github/workflows/jekyll-build.yml
23-
with:
24-
target_branch: gh-pages
25-
clean_gh_pages: true
2625
secrets:
2726
GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
2827
GH_BOT_NAME: ${{ secrets.GH_BOT_NAME }}
2928
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
29+
with:
30+
target_branch: gh-pages
31+
clean_gh_pages: true
3032

3133
release:
3234
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
35+
permissions:
36+
contents: write # needed for setup-release-action
3337
runs-on: ubuntu-latest
3438
steps:
3539
- name: Setup Release

.github/workflows/codeql.yml

+46-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
---
2-
# This action is centrally managed in https://github.com/<organization>/.github/
2+
# This workflow is centrally managed in https://github.com/<organization>/.github/
33
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
44
# the above-mentioned repo.
55

66
# This workflow will analyze all supported languages in the repository using CodeQL Analysis.
77

88
name: "CodeQL"
9+
permissions:
10+
contents: read
911

1012
on:
1113
push:
12-
branches: ["master"]
14+
branches:
15+
- master
1316
pull_request:
14-
branches: ["master"]
17+
branches:
18+
- master
1519
schedule:
1620
- cron: '00 12 * * 0' # every Sunday at 12:00 UTC
1721

@@ -22,14 +26,17 @@ concurrency:
2226
jobs:
2327
languages:
2428
name: Get language matrix
25-
runs-on: ubuntu-latest
2629
outputs:
2730
matrix: ${{ steps.lang.outputs.result }}
2831
continue: ${{ steps.continue.outputs.result }}
32+
runs-on: ubuntu-latest
2933
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
36+
3037
- name: Get repo languages
31-
uses: actions/github-script@v7
3238
id: lang
39+
uses: actions/github-script@v7
3340
with:
3441
script: |
3542
// CodeQL supports ['cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift']
@@ -54,6 +61,22 @@ jobs:
5461
// Track languages we've already added to avoid duplicates
5562
const addedLanguages = new Set()
5663
64+
// Check if workflow files exist to determine if we should add actions language
65+
const fs = require('fs');
66+
const hasYmlFiles = fs.existsSync('.github/workflows') &&
67+
fs.readdirSync('.github/workflows').some(file => file.endsWith('.yml') || file.endsWith('.yaml'));
68+
69+
// Add actions language if workflow files exist
70+
if (hasYmlFiles) {
71+
console.log('Found GitHub Actions workflow files. Adding actions to the matrix.');
72+
matrix['include'].push({
73+
"category": "/language:actions",
74+
"language": "actions",
75+
"name": "actions",
76+
"os": "ubuntu-latest"
77+
});
78+
}
79+
5780
for (let [key, value] of Object.entries(response.data)) {
5881
// remap language
5982
if (remap_languages[key.toLowerCase()]) {
@@ -78,11 +101,18 @@ jobs:
78101
// set name for matrix
79102
let name = osList.length === 1 ? normalizedKey : `${normalizedKey}, ${os}`
80103
104+
// set category for matrix
105+
let category = `/language:${normalizedKey}`
106+
if (normalizedKey === 'cpp') {
107+
category = `/language:cpp-${os.split('-')[0]}`
108+
}
109+
81110
// add to matrix
82111
matrix['include'].push({
112+
"category": category,
83113
"language": normalizedKey,
84-
"os": os,
85-
"name": name
114+
"name": name,
115+
"os": os
86116
})
87117
}
88118
}
@@ -94,8 +124,8 @@ jobs:
94124
return matrix
95125
96126
- name: Continue
97-
uses: actions/github-script@v7
98127
id: continue
128+
uses: actions/github-script@v7
99129
with:
100130
script: |
101131
// if matrix['include'] is an empty list return false, otherwise true
@@ -109,24 +139,22 @@ jobs:
109139
110140
analyze:
111141
name: Analyze (${{ matrix.name }})
112-
if: ${{ needs.languages.outputs.continue == 'true' }}
142+
if: needs.languages.outputs.continue == 'true'
113143
defaults:
114144
run:
115145
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
116146
env:
117147
GITHUB_CODEQL_BUILD: true
118-
needs: [languages]
119-
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
120-
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
148+
needs: languages
121149
permissions:
122150
actions: read
123151
contents: read
124152
security-events: write
125-
153+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
126154
strategy:
127155
fail-fast: false
128156
matrix: ${{ fromJson(needs.languages.outputs.matrix) }}
129-
157+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
130158
steps:
131159
- name: Maximize build space
132160
if: >-
@@ -174,8 +202,7 @@ jobs:
174202
- third-party
175203
176204
# Pre autobuild
177-
# create a file named .codeql-prebuild-${{ matrix.language }}.sh in the root of your repository
178-
# create a file named .codeql-build-${{ matrix.language }}.sh in the root of your repository
205+
# create a file named .codeql-prebuild-${{ matrix.language }}-${{ runner.os }}.sh in the root of your repository
179206
- name: Prebuild
180207
id: prebuild
181208
run: |
@@ -194,7 +221,7 @@ jobs:
194221
- name: Perform CodeQL Analysis
195222
uses: github/codeql-action/analyze@v3
196223
with:
197-
category: "/language:${{matrix.language}}"
224+
category: "${{ matrix.category }}"
198225
output: sarif-results
199226
upload: failure-only
200227

@@ -211,11 +238,13 @@ jobs:
211238
- name: Upload SARIF
212239
uses: github/codeql-action/upload-sarif@v3
213240
with:
241+
category: "${{ matrix.category }}"
214242
sarif_file: sarif-results/${{ matrix.language }}.sarif
215243

216244
- name: Upload loc as a Build Artifact
217245
uses: actions/upload-artifact@v4
218246
with:
219247
name: sarif-results-${{ matrix.language }}-${{ runner.os }}
220248
path: sarif-results
249+
if-no-files-found: error
221250
retention-days: 1

.github/workflows/common-lint.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
---
2-
# This action is centrally managed in https://github.com/<organization>/.github/
2+
# This workflow is centrally managed in https://github.com/<organization>/.github/
33
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
44
# the above-mentioned repo.
55

66
# Common linting.
77

88
name: common lint
9+
permissions:
10+
contents: read
911

1012
on:
1113
pull_request:
12-
branches: [master]
13-
types: [opened, synchronize, reopened]
14+
branches:
15+
- master
16+
types:
17+
- opened
18+
- synchronize
19+
- reopened
1420

1521
concurrency:
1622
group: "${{ github.workflow }}-${{ github.ref }}"
@@ -77,9 +83,10 @@ jobs:
7783
7884
- name: C++ - Clang format lint
7985
if: always() && steps.cpp_files.outputs.found_files
80-
uses: DoozyX/clang-format-lint-action@v0.18
86+
uses: DoozyX/clang-format-lint-action@v0.20
8187
with:
8288
source: ${{ steps.cpp_files.outputs.found_files }}
89+
clangFormatVersion: '20'
8390
extensions: 'c,cpp,h,hpp,m,mm'
8491
style: file
8592
inplace: false
@@ -263,5 +270,4 @@ jobs:
263270

264271
- name: YAML - log
265272
if: always() && steps.yamllint.outcome == 'failure'
266-
run: |
267-
cat "${{ steps.yamllint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY
273+
run: cat "${{ steps.yamllint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY

.github/workflows/issues.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
---
2-
# This action is centrally managed in https://github.com/<organization>/.github/
2+
# This workflow is centrally managed in https://github.com/<organization>/.github/
33
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
44
# the above-mentioned repo.
55

66
# Label and un-label actions using `../label-actions.yml`.
77

88
name: Issues
9+
permissions: {}
910

1011
on:
1112
issues:
12-
types: [labeled, unlabeled]
13+
types:
14+
- labeled
15+
- unlabeled
1316
discussion:
14-
types: [labeled, unlabeled]
17+
types:
18+
- labeled
19+
- unlabeled
1520

1621
jobs:
1722
label:

.github/workflows/jekyll-build.yml

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
name: Build Jekyll
3+
permissions:
4+
contents: read
35

46
on:
57
workflow_call:
@@ -83,14 +85,14 @@ jobs:
8385
path: theme
8486

8587
- name: Download input artifact
86-
if: ${{ inputs.site_artifact != '' }}
88+
if: inputs.site_artifact != ''
8789
uses: actions/download-artifact@v4
8890
with:
8991
name: ${{ inputs.site_artifact }}
9092
path: project
9193

9294
- name: Extract archive
93-
if: ${{ inputs.site_artifact != '' && inputs.extract_archive != '' }}
95+
if: inputs.site_artifact != '' && inputs.extract_archive != ''
9496
working-directory: project
9597
run: |
9698
case "${{ inputs.extract_archive }}" in
@@ -111,7 +113,7 @@ jobs:
111113
rm -f "${{ inputs.extract_archive }}"
112114
113115
- name: Setup project
114-
if: ${{ github.repository == 'LizardByte/LizardByte.github.io' }}
116+
if: github.repository == 'LizardByte/LizardByte.github.io'
115117
run: |
116118
mkdir -p ./project
117119
cp -RT ./theme/ ./project/
@@ -172,8 +174,7 @@ jobs:
172174
ruby-version: '3.3'
173175

174176
- name: Install dependencies
175-
run: |
176-
bundle install
177+
run: bundle install
177178

178179
- name: Setup Pages
179180
id: configure-pages
@@ -208,8 +209,7 @@ jobs:
208209
209210
- name: Prepare Artifacts # uploading artifacts may fail if not zipped due to very large quantity of files
210211
shell: bash
211-
run: |
212-
7z a _site.zip ./_site/*
212+
run: 7z a _site.zip ./_site/*
213213

214214
- name: Upload artifact
215215
uses: actions/upload-artifact@v4
@@ -224,8 +224,8 @@ jobs:
224224
name: Deploy to Pages
225225
if: >-
226226
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
227-
(github.event_name == 'schedule') ||
228-
(github.event_name == 'workflow_dispatch')
227+
github.event_name == 'schedule' ||
228+
github.event_name == 'workflow_dispatch'
229229
runs-on: ubuntu-latest
230230
needs: build
231231
steps:
@@ -237,11 +237,10 @@ jobs:
237237
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
238238
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
239239

240+
# empty contents of gh-pages
240241
- name: Clean
241-
if: ${{ inputs.clean_gh_pages }}
242-
run: |
243-
# empty contents of gh-pages
244-
rm -f -r ./gh-pages/*
242+
if: inputs.clean_gh_pages
243+
run: rm -f -r ./gh-pages/*
245244

246245
- name: Download artifact
247246
uses: actions/download-artifact@v4

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ This repo contains a reusable workflow to allow for building gh-pages subproject
2525
```yml
2626
---
2727
name: Jekyll CI
28+
permissions:
29+
contents: read
2830

2931
on:
3032
pull_request:
@@ -61,14 +63,14 @@ jobs:
6163
call-jekyll-build:
6264
needs: prep
6365
uses: LizardByte/LizardByte.github.io/.github/workflows/jekyll-build.yml@master
64-
with:
65-
site_artifact: 'prep' # any name except 'site' is allowed
66-
target_branch: 'gh-pages'
67-
clean_gh_pages: true
6866
secrets:
6967
GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
7068
GH_BOT_NAME: ${{ secrets.GH_BOT_NAME }}
7169
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
70+
with:
71+
site_artifact: 'prep' # any name except 'site' is allowed
72+
target_branch: 'gh-pages'
73+
clean_gh_pages: true
7274
```
7375
7476
For additional options see [jekyll-build.yml](.github/workflows/jekyll-build.yml)

0 commit comments

Comments
 (0)