Skip to content

Commit 6f12daa

Browse files
chore: update global workflows
1 parent 77b1b55 commit 6f12daa

File tree

3 files changed

+47
-17
lines changed

3 files changed

+47
-17
lines changed

.github/workflows/codeql.yml

+31-11
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
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,21 @@ 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+
"language": "actions",
74+
"os": "ubuntu-latest",
75+
"name": "actions"
76+
});
77+
}
78+
5779
for (let [key, value] of Object.entries(response.data)) {
5880
// remap language
5981
if (remap_languages[key.toLowerCase()]) {
@@ -94,8 +116,8 @@ jobs:
94116
return matrix
95117
96118
- name: Continue
97-
uses: actions/github-script@v7
98119
id: continue
120+
uses: actions/github-script@v7
99121
with:
100122
script: |
101123
// if matrix['include'] is an empty list return false, otherwise true
@@ -109,24 +131,22 @@ jobs:
109131
110132
analyze:
111133
name: Analyze (${{ matrix.name }})
112-
if: ${{ needs.languages.outputs.continue == 'true' }}
134+
if: needs.languages.outputs.continue == 'true'
113135
defaults:
114136
run:
115137
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
116138
env:
117139
GITHUB_CODEQL_BUILD: true
118-
needs: [languages]
119-
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
120-
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
140+
needs: languages
121141
permissions:
122142
actions: read
123143
contents: read
124144
security-events: write
125-
145+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
126146
strategy:
127147
fail-fast: false
128148
matrix: ${{ fromJson(needs.languages.outputs.matrix) }}
129-
149+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
130150
steps:
131151
- name: Maximize build space
132152
if: >-

.github/workflows/common-lint.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@
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 }}"
@@ -263,5 +269,4 @@ jobs:
263269

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

.github/workflows/issues.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
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:

0 commit comments

Comments
 (0)