Skip to content

Commit 0e993a7

Browse files
chore: update global workflows
1 parent 668a5d5 commit 0e993a7

File tree

3 files changed

+70
-15
lines changed

3 files changed

+70
-15
lines changed

.github/workflows/codeql.yml

Lines changed: 31 additions & 11 deletions
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

Lines changed: 9 additions & 4 deletions
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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
# This action is centrally managed in https://github.com/<organization>/.github/
3+
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
4+
# the above-mentioned repo.
5+
6+
# Label and un-label actions using `../label-actions.yml`.
7+
8+
name: Issues
9+
permissions: {}
10+
11+
on:
12+
issues:
13+
types:
14+
- labeled
15+
- unlabeled
16+
discussion:
17+
types:
18+
- labeled
19+
- unlabeled
20+
21+
jobs:
22+
label:
23+
name: Label Actions
24+
if: startsWith(github.repository, 'LizardByte/')
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Label Actions
28+
uses: dessant/label-actions@v4
29+
with:
30+
github-token: ${{ secrets.GH_BOT_TOKEN }}

0 commit comments

Comments
 (0)