Skip to content

Commit 8c98d4e

Browse files
authored
ci: update of files from global .github repo (#224)
1 parent ab9a8c8 commit 8c98d4e

32 files changed

Lines changed: 1099 additions & 926 deletions

.github/workflows/add-good-first-issue-labels.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ on:
99
types:
1010
- created
1111

12+
permissions: {}
13+
1214
jobs:
1315
add-labels:
14-
if: ${{(!github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot') && (contains(github.event.comment.body, '/good-first-issue') || contains(github.event.comment.body, '/gfi' ))}}
16+
name: Add 'Good First Issue' and 'area/*' labels
17+
if: ${{(!github.event.issue.pull_request && github.event.issue.state != 'closed' && github.event.comment.user.login != 'asyncapi-bot') && (contains(github.event.comment.body, '/good-first-issue') || contains(github.event.comment.body, '/gfi' ))}}
1518
runs-on: ubuntu-latest
19+
permissions:
20+
issues: write # This is needed to add labels to issues.
1621
steps:
1722
- name: Add label
18-
uses: actions/github-script@v7
23+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
1924
with:
20-
github-token: ${{ secrets.GH_TOKEN }}
25+
github-token: ${{ github.token }}
2126
script: |
2227
const areas = ['javascript', 'typescript', 'java' , 'go', 'docs', 'ci-cd', 'design'];
2328
const words = context.payload.comment.body.trim().split(" ");

.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ on:
1212
types:
1313
- created
1414

15+
permissions: {}
16+
1517
jobs:
1618
add-ready-to-merge-label:
19+
name: Add ready-to-merge label
20+
permissions:
21+
issues: write # required to add labels and post comments on PR issues
22+
pull-requests: write # required to read PR metadata from the issue pull_request URL
23+
contents: read # required to compare PR branch commits against base
1724
if: >
1825
github.event.issue.pull_request &&
1926
github.event.issue.state != 'closed' &&
20-
github.actor != 'asyncapi-bot' &&
27+
github.event.comment.user.login != 'asyncapi-bot' &&
2128
(
2229
contains(github.event.comment.body, '/ready-to-merge') ||
2330
contains(github.event.comment.body, '/rtm' )
@@ -26,10 +33,13 @@ jobs:
2633
runs-on: ubuntu-latest
2734
steps:
2835
- name: Add ready-to-merge label
29-
uses: actions/github-script@v7
36+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
3037
env:
3138
GITHUB_ACTOR: ${{ github.actor }}
3239
with:
40+
# Use bot PAT, not the default GITHUB_TOKEN: events created by
41+
# GITHUB_TOKEN do not trigger other workflows, so `Automerge For
42+
# Humans` would never see the `labeled` event.
3343
github-token: ${{ secrets.GH_TOKEN }}
3444
script: |
3545
const prDetailsUrl = context.payload.issue.pull_request.url;
@@ -69,19 +79,24 @@ jobs:
6979
}
7080
7181
add-do-not-merge-label:
82+
name: Add do-not-merge label
83+
permissions:
84+
issues: write # required to add labels on PR issues
85+
pull-requests: write # required to read PR metadata from the issue pull_request URL
7286
if: >
7387
github.event.issue.pull_request &&
7488
github.event.issue.state != 'closed' &&
75-
github.actor != 'asyncapi-bot' &&
89+
github.event.comment.user.login != 'asyncapi-bot' &&
7690
(
7791
contains(github.event.comment.body, '/do-not-merge') ||
7892
contains(github.event.comment.body, '/dnm' )
7993
)
8094
runs-on: ubuntu-latest
8195
steps:
8296
- name: Add do-not-merge label
83-
uses: actions/github-script@v7
97+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
8498
with:
99+
# Bot PAT so the `labeled` event can trigger downstream workflows.
85100
github-token: ${{ secrets.GH_TOKEN }}
86101
script: |
87102
github.rest.issues.addLabels({
@@ -91,19 +106,24 @@ jobs:
91106
labels: ['do-not-merge']
92107
})
93108
add-autoupdate-label:
109+
name: Add autoupdate label
110+
permissions:
111+
issues: write # required to add labels on PR issues
112+
pull-requests: write # required to read PR metadata from the issue pull_request URL
94113
if: >
95114
github.event.issue.pull_request &&
96115
github.event.issue.state != 'closed' &&
97-
github.actor != 'asyncapi-bot' &&
116+
github.event.comment.user.login != 'asyncapi-bot' &&
98117
(
99118
contains(github.event.comment.body, '/autoupdate') ||
100119
contains(github.event.comment.body, '/au' )
101120
)
102121
runs-on: ubuntu-latest
103122
steps:
104123
- name: Add autoupdate label
105-
uses: actions/github-script@v7
124+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
106125
with:
126+
# Bot PAT so the `labeled` event can trigger the autoupdate workflow.
107127
github-token: ${{ secrets.GH_TOKEN }}
108128
script: |
109129
github.rest.issues.addLabels({

.github/workflows/automerge-for-humans-merging.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,25 @@ on:
1414
- edited
1515
- ready_for_review
1616
- reopened
17-
- unlocked
17+
- unlocked # zizmor: ignore[dangerous-triggers] needed if we want author to be our bot
18+
19+
permissions: {}
1820

1921
jobs:
2022
automerge-for-humans:
23+
name: Automerge PRs labeled with ready-to-merge
24+
permissions:
25+
contents: read # required for PR commit metadata reads
26+
pull-requests: read # required to read pull request details in github-script steps
2127
# it runs only if PR actor is not a bot, at least not a bot that we know
2228
if: |
2329
github.event.pull_request.draft == false &&
24-
(github.event.pull_request.user.login != 'asyncapi-bot' ||
25-
github.event.pull_request.user.login != 'dependabot[bot]' ||
26-
github.event.pull_request.user.login != 'dependabot-preview[bot]')
30+
!contains(fromJSON('["asyncapi-bot","dependabot[bot]","dependabot-preview[bot]"]'), github.event.pull_request.user.login)
2731
runs-on: ubuntu-latest
2832
steps:
2933
- name: Get PR authors
3034
id: authors
31-
uses: actions/github-script@v7
35+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
3236
with:
3337
script: |
3438
// Get paginated list of all commits in the PR
@@ -67,10 +71,12 @@ jobs:
6771
6872
- name: Create commit message
6973
id: create-commit-message
70-
uses: actions/github-script@v7
74+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
75+
env:
76+
AUTHORS_JSON: ${{ steps.authors.outputs.result }}
7177
with:
7278
script: |
73-
const authors = ${{ steps.authors.outputs.result }};
79+
const authors = JSON.parse(process.env.AUTHORS_JSON);
7480
7581
if (Object.keys(authors).length === 0) {
7682
core.setFailed('No authors found in the PR');

.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@ on:
99
pull_request_target:
1010
types:
1111
- synchronize
12-
- edited
12+
- edited # zizmor: ignore[dangerous-triggers] needed as pull_request token is read-only
13+
14+
permissions: {}
1315

1416
jobs:
1517
remove-ready-label:
18+
name: Remove ready-to-merge label
1619
runs-on: ubuntu-latest
20+
permissions:
21+
pull-requests: write # required to remove labels and post comments on PR issues
1722
steps:
1823
- name: Remove label
19-
uses: actions/github-script@v7
24+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
2025
with:
21-
github-token: ${{ secrets.GH_TOKEN }}
26+
github-token: ${{ github.token }}
2227
script: |
2328
const labelToRemove = 'ready-to-merge';
2429
const labels = context.payload.pull_request.labels;

.github/workflows/automerge-orphans.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,26 @@ on:
77
schedule:
88
- cron: "0 0 * * *"
99

10+
permissions: {}
11+
1012
jobs:
1113
identify-orphans:
1214
if: startsWith(github.repository, 'asyncapi/')
1315
name: Find orphans and notify
16+
permissions:
17+
contents: read # required by checkout and repository metadata reads
18+
pull-requests: read # required to list open pull requests
1419
runs-on: ubuntu-latest
1520
steps:
1621
- name: Checkout repository
17-
uses: actions/checkout@v4
22+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
23+
with:
24+
persist-credentials: false
1825
- name: Get list of orphans
19-
uses: actions/github-script@v7
26+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
2027
id: orphans
2128
with:
22-
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
github-token: ${{ github.token }}
2330
script: |
2431
const query = `query($owner:String!, $name:String!) {
2532
repository(owner:$owner, name:$name){

.github/workflows/automerge.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
name: Automerge PRs from bots
55

66
on:
7-
pull_request_target:
7+
pull_request_target: # Needed as GH_TOKEN_BOT_EVE needed for approval.
88
types:
99
- opened
10-
- synchronize
10+
- synchronize # zizmor: ignore[dangerous-triggers]
11+
12+
permissions: {}
1113

1214
jobs:
1315
autoapprove-for-bot:
1416
name: Autoapprove PR comming from a bot
1517
if: >
1618
contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.event.pull_request.user.login) &&
17-
contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.actor) &&
1819
!contains(github.event.pull_request.labels.*.name, 'released')
1920
runs-on: ubuntu-latest
2021
steps:
@@ -24,7 +25,7 @@ jobs:
2425
github-token: "${{ secrets.GH_TOKEN_BOT_EVE }}"
2526

2627
- name: Label autoapproved
27-
uses: actions/github-script@v7
28+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
2829
with:
2930
github-token: ${{ secrets.GH_TOKEN }}
3031
script: |

.github/workflows/autoupdate.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ on:
1818
- 'bot/**'
1919
- 'all-contributors/**'
2020

21+
permissions: {}
22+
2123
jobs:
2224
autoupdate-for-bot:
2325
if: startsWith(github.repository, 'asyncapi/')
2426
name: Autoupdate autoapproved PR created in the upstream
2527
runs-on: ubuntu-latest
2628
steps:
2729
- name: Autoupdating
28-
uses: docker://chinthakagodawita/autoupdate-action:v1
30+
uses: chinthakagodawita/autoupdate@0707656cd062a3b0cf8fa9b2cda1d1404d74437e
2931
env:
3032
GITHUB_TOKEN: '${{ secrets.GH_TOKEN_BOT_EVE }}'
3133
PR_FILTER: "labelled"

.github/workflows/bounty-program-commands.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ env:
2020
{"name": "bounty", "color": "0e8a16", "description": "Participation in the Bounty Program"}
2121
]
2222
23+
permissions: {}
24+
2325
jobs:
2426
guard-against-unauthorized-use:
27+
name: Guard against unauthorized use
28+
permissions:
29+
issues: write # required to post a comment on the issue/PR
30+
pull-requests: write # required to post a comment on the issue/PR if it's a PR
2531
if: >
26-
github.actor != ('aeworxet' || 'thulieblack') &&
32+
!contains(fromJSON('["aeworxet","thulieblack"]'), github.event.comment.user.login) &&
2733
(
2834
startsWith(github.event.comment.body, '/bounty' )
2935
)
@@ -32,11 +38,11 @@ jobs:
3238

3339
steps:
3440
- name: ❌ @${{github.actor}} made an unauthorized attempt to use a Bounty Program's command
35-
uses: actions/github-script@v7
41+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
3642
env:
3743
ACTOR: ${{ github.actor }}
3844
with:
39-
github-token: ${{ secrets.GH_TOKEN }}
45+
github-token: ${{ github.token }}
4046
script: |
4147
const commentText = `❌ @${process.env.ACTOR} is not authorized to use the Bounty Program's commands.
4248
These commands can only be used by members of the [Bounty Team](https://github.com/orgs/asyncapi/teams/bounty_team).`;
@@ -50,19 +56,22 @@ jobs:
5056
})
5157
5258
add-label-bounty:
59+
name: Add bounty label
60+
permissions:
61+
issues: write # required to read/create labels and add labels on the issue/PR
62+
pull-requests: write # required to read/create labels and add labels on the issue/PR
5363
if: >
54-
github.actor == ('aeworxet' || 'thulieblack') &&
64+
contains(fromJSON('["aeworxet","thulieblack"]'), github.event.comment.user.login) &&
5565
(
5666
startsWith(github.event.comment.body, '/bounty' )
5767
)
5868
5969
runs-on: ubuntu-latest
60-
6170
steps:
6271
- name: Add label `bounty`
63-
uses: actions/github-script@v7
72+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
6473
with:
65-
github-token: ${{ secrets.GH_TOKEN }}
74+
github-token: ${{ github.token }}
6675
script: |
6776
const BOUNTY_PROGRAM_LABELS = JSON.parse(process.env.BOUNTY_PROGRAM_LABELS_JSON);
6877
let LIST_OF_LABELS_FOR_REPO = await github.rest.issues.listLabelsForRepo({
@@ -91,19 +100,21 @@ jobs:
91100
})
92101
93102
remove-label-bounty:
103+
name: Remove bounty label
104+
permissions:
105+
issues: write # required to read/remove labels on the issue/PR
106+
pull-requests: write # required to read/remove labels on the issue/PR if it's a PR
94107
if: >
95-
github.actor == ('aeworxet' || 'thulieblack') &&
108+
contains(fromJSON('["aeworxet","thulieblack"]'), github.event.comment.user.login) &&
96109
(
97110
startsWith(github.event.comment.body, '/unbounty' )
98111
)
99-
100112
runs-on: ubuntu-latest
101-
102113
steps:
103114
- name: Remove label `bounty`
104-
uses: actions/github-script@v7
115+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
105116
with:
106-
github-token: ${{ secrets.GH_TOKEN }}
117+
github-token: ${{ github.token }}
107118
script: |
108119
const BOUNTY_PROGRAM_LABELS = JSON.parse(process.env.BOUNTY_PROGRAM_LABELS_JSON);
109120
let LIST_OF_LABELS_FOR_ISSUE = await github.rest.issues.listLabelsOnIssue({

.github/workflows/bump.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ on:
1313
branches:
1414
- master
1515

16+
permissions:
17+
contents: read # To checkout code
18+
1619
jobs:
1720
bump-in-dependent-projects:
1821
name: Bump this package in repositories that depend on it
1922
if: startsWith(github.event.commits[0].message, 'chore(release):')
2023
runs-on: ubuntu-latest
2124
steps:
2225
- name: Checkout repo
23-
uses: actions/checkout@v4
26+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
27+
with:
28+
persist-credentials: false
2429
- name: Check if Node.js project and has package.json
2530
id: packagejson
26-
run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
31+
run: test -e ./package.json && echo "exists=true" >> "$GITHUB_OUTPUT" || echo "exists=false" >> "$GITHUB_OUTPUT"
2732
- name: Setup corepack with pnpm and yarn
2833
if: steps.packagejson.outputs.exists == 'true'
2934
run: corepack enable

0 commit comments

Comments
 (0)