Skip to content

Commit c4a6232

Browse files
committed
zizmor: fix issues
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 1359948 commit c4a6232

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed
Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,51 @@
11
name: .pr-assign-author
22

3+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
34
permissions:
45
contents: read
56

67
on:
7-
pull_request_target:
8+
pull_request_target: # zizmor: ignore[dangerous-triggers] safe to use without checkout
89
types:
910
- opened
1011
- reopened
1112

1213
jobs:
13-
run:
14-
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@1b673f36fad86812f538c1df9794904038a23cbf
14+
assign-author:
15+
runs-on: ubuntu-24.04
1516
permissions:
1617
contents: read
1718
pull-requests: write
19+
steps:
20+
-
21+
name: Assigning author to PR
22+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
23+
with:
24+
script: |
25+
try {
26+
const dt = context.payload?.pull_request;
27+
if (!dt) {
28+
throw new Error(`No pull request payload found, skipping.`);
29+
}
30+
31+
const { assignees, number, user: { login: author, type } } = dt;
32+
if (assignees.length > 0) {
33+
throw new Error(`Pull request is already assigned to someone, skipping.`);
34+
} else if (type !== 'User') {
35+
throw new Error(`Not a user, skipping.`);
36+
}
37+
38+
const respAdd = await github.rest.issues.addAssignees({
39+
...context.repo,
40+
issue_number: number,
41+
assignees: [author]
42+
});
43+
core.debug(`addAssignees resp: ${JSON.stringify(respAdd, null, 2)}`);
44+
if (respAdd.status !== 201) {
45+
throw new Error(`Failed to assign @${author} to the pull request #${number}.`);
46+
}
47+
48+
core.info(`@${author} has been assigned to the pull request #${number}`);
49+
} catch (e) {
50+
core.warning(e.message);
51+
}

.github/workflows/.test-bake.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: .test-bake
22

3+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
4+
permissions:
5+
contents: read
6+
37
concurrency:
48
group: ${{ github.workflow }}-${{ github.ref }}
59
cancel-in-progress: true

.github/workflows/.test-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: .test-build
22

3+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
4+
permissions:
5+
contents: read
6+
37
concurrency:
48
group: ${{ github.workflow }}-${{ github.ref }}
59
cancel-in-progress: true

.github/workflows/.zizmor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ name: .zizmor
44
permissions:
55
contents: read
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
on:
812
workflow_dispatch:
913
push:

0 commit comments

Comments
 (0)