Skip to content

Commit f67a6ad

Browse files
authored
ci: update of files from global .github repo (#2139)
1 parent 1e3f366 commit f67a6ad

23 files changed

Lines changed: 253 additions & 135 deletions

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

Lines changed: 6 additions & 1 deletion
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:
16+
name: Add 'Good First Issue' and 'area/*' labels
1417
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' ))}}
1518
runs-on: ubuntu-latest
19+
permissions:
20+
issues: write # This is needed to add labels to issues.
1621
steps:
1722
- name: Add label
1823
uses: actions/github-script@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: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ 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' &&
@@ -30,7 +37,7 @@ jobs:
3037
env:
3138
GITHUB_ACTOR: ${{ github.actor }}
3239
with:
33-
github-token: ${{ secrets.GH_TOKEN }}
40+
github-token: ${{ github.token }}
3441
script: |
3542
const prDetailsUrl = context.payload.issue.pull_request.url;
3643
const { data: pull } = await github.request(prDetailsUrl);
@@ -69,6 +76,10 @@ jobs:
6976
}
7077
7178
add-do-not-merge-label:
79+
name: Add do-not-merge label
80+
permissions:
81+
issues: write # required to add labels on PR issues
82+
pull-requests: write # required to read PR metadata from the issue pull_request URL
7283
if: >
7384
github.event.issue.pull_request &&
7485
github.event.issue.state != 'closed' &&
@@ -82,7 +93,7 @@ jobs:
8293
- name: Add do-not-merge label
8394
uses: actions/github-script@v7
8495
with:
85-
github-token: ${{ secrets.GH_TOKEN }}
96+
github-token: ${{ github.token }}
8697
script: |
8798
github.rest.issues.addLabels({
8899
issue_number: context.issue.number,
@@ -91,6 +102,10 @@ jobs:
91102
labels: ['do-not-merge']
92103
})
93104
add-autoupdate-label:
105+
name: Add autoupdate label
106+
permissions:
107+
issues: write # required to add labels on PR issues
108+
pull-requests: write # required to read PR metadata from the issue pull_request URL
94109
if: >
95110
github.event.issue.pull_request &&
96111
github.event.issue.state != 'closed' &&
@@ -104,7 +119,7 @@ jobs:
104119
- name: Add autoupdate label
105120
uses: actions/github-script@v7
106121
with:
107-
github-token: ${{ secrets.GH_TOKEN }}
122+
github-token: ${{ github.token }}
108123
script: |
109124
github.rest.issues.addLabels({
110125
issue_number: context.issue.number,

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ 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
@@ -68,9 +72,11 @@ jobs:
6872
- name: Create commit message
6973
id: create-commit-message
7074
uses: actions/github-script@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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,24 @@
66
name: Remove ready-to-merge label
77

88
on:
9-
pull_request_target:
9+
pull_request:
1010
types:
1111
- synchronize
1212
- edited
1313

14+
permissions: {}
15+
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
1924
uses: actions/github-script@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: 8 additions & 1 deletion
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
1722
uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
1825
- name: Get list of orphans
1926
uses: actions/github-script@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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
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:

.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: 20 additions & 9 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.actor) &&
2733
(
2834
startsWith(github.event.comment.body, '/bounty' )
2935
)
@@ -36,7 +42,7 @@ jobs:
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.actor) &&
5565
(
5666
startsWith(github.event.comment.body, '/bounty' )
5767
)
5868
5969
runs-on: ubuntu-latest
60-
6170
steps:
6271
- name: Add label `bounty`
6372
uses: actions/github-script@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.actor) &&
96109
(
97110
startsWith(github.event.comment.body, '/unbounty' )
98111
)
99-
100112
runs-on: ubuntu-latest
101-
102113
steps:
103114
- name: Remove label `bounty`
104115
uses: actions/github-script@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/help-command.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,26 @@
44
name: Create help comment
55

66
on:
7-
issue_comment:
8-
types:
9-
- created
7+
issue_comment:
8+
types:
9+
- created
10+
11+
permissions: {}
1012

1113
jobs:
1214
create_help_comment_pr:
15+
name: Help Comment in PR
1316
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }}
1417
runs-on: ubuntu-latest
18+
permissions:
19+
pull-requests: write # To comment on Pull requests
1520
steps:
1621
- name: Add comment to PR
1722
uses: actions/github-script@v7
1823
env:
1924
ACTOR: ${{ github.actor }}
2025
with:
21-
github-token: ${{ secrets.GH_TOKEN }}
26+
github-token: ${{ github.token }}
2227
script: |
2328
//Yes to add comment to PR the same endpoint is use that we use to create a comment in issue
2429
//For more details http://developer.github.com/v3/issues/comments/
@@ -41,15 +46,18 @@ jobs:
4146
})
4247

4348
create_help_comment_issue:
49+
name: Help Comment in Issue
4450
if: ${{ !github.event.issue.pull_request && startsWith(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }}
4551
runs-on: ubuntu-latest
52+
permissions:
53+
issues: write # To comment on Issues
4654
steps:
4755
- name: Add comment to Issue
4856
uses: actions/github-script@v7
4957
env:
5058
ACTOR: ${{ github.actor }}
5159
with:
52-
github-token: ${{ secrets.GH_TOKEN }}
60+
github-token: ${{ github.token }}
5361
script: |
5462
github.rest.issues.createComment({
5563
issue_number: context.issue.number,

.github/workflows/if-docker-pr-testing.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
env:
1111
IMAGE_NAME: ${{ github.repository }}
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
test-docker-pr:
1518
name: Test Docker build
@@ -18,30 +21,32 @@ jobs:
1821
steps:
1922
- if: >
2023
!github.event.pull_request.draft && !(
21-
(github.actor == 'asyncapi-bot' && (
24+
(github.event.pull_request.user.login == 'asyncapi-bot' && (
2225
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
2326
startsWith(github.event.pull_request.title, 'chore(release):')
2427
)) ||
25-
(github.actor == 'asyncapi-bot-eve' && (
28+
(github.event.pull_request.user.login == 'asyncapi-bot-eve' && (
2629
startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') ||
2730
startsWith(github.event.pull_request.title, 'chore(release):')
2831
)) ||
29-
(github.actor == 'allcontributors[bot]' &&
32+
(github.event.pull_request.user.login == 'allcontributors[bot]' &&
3033
startsWith(github.event.pull_request.title, 'docs: add')
3134
)
3235
)
3336
id: should_run
3437
name: Should Run
35-
run: echo "shouldrun=true" >> $GITHUB_OUTPUT
38+
run: echo "shouldrun=true" >> "$GITHUB_OUTPUT"
3639
3740
- if: steps.should_run.outputs.shouldrun == 'true'
3841
name: Checkout repository
3942
uses: actions/checkout@v4
43+
with:
44+
persist-credentials: false
4045

4146
- if: steps.should_run.outputs.shouldrun == 'true'
4247
name: Check if project has a Dockerfile
4348
id: docker
44-
run: test -e ./Dockerfile && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
49+
run: test -e ./Dockerfile && echo "exists=true" >> "$GITHUB_OUTPUT" || echo "exists=false" >> "$GITHUB_OUTPUT"
4550
shell: bash
4651

4752
- if: steps.docker.outputs.exists == 'true'

0 commit comments

Comments
 (0)