Skip to content

Commit 100c4ad

Browse files
committed
github: modify actions to comment on failures
1 parent b1e90b7 commit 100c4ad

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

.github/workflows/build-prev.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Build Docs Preview
22

3+
permissions:
4+
pull-requests: write
5+
36
on:
47
pull_request:
58

@@ -12,9 +15,6 @@ jobs:
1215
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
1316
ALGOLIA_SEARCH_API_KEY: ${{ secrets.ALGOLIA_SEARCH_API_KEY }}
1417
NODE_OPTIONS: --max_old_space_size=8192
15-
permissions:
16-
contents: read
17-
deployments: write
1818
steps:
1919
- uses: actions/checkout@v4
2020
- uses: pnpm/action-setup@v4
@@ -27,13 +27,17 @@ jobs:
2727
continue-on-error: true
2828
- name: Comment on build failure with log link
2929
if: ${{ steps.build.outcome == 'failure' }}
30-
uses: peter-evans/create-or-update-comment@v2
30+
uses: actions/github-script@v6
3131
with:
32-
token: ${{ secrets.GITHUB_TOKEN }}
33-
issue-number: ${{ github.event.pull_request.number }}
34-
body: |
35-
## Build Failed
36-
The build has failed. You can review the full build logs and download the build log artifact via the [workflow run details](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
32+
github-token: ${{ secrets.GITHUB_TOKEN }}
33+
script: |
34+
github.rest.issues.createComment({
35+
issue_number: context.issue.number,
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
body: `## Build Failed
39+
The build has failed. You can review the full build logs and download the build log artifact via the [workflow run details](https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}).`
40+
});
3741
- name: Fail if build failed
3842
if: ${{ steps.build.outcome == 'failure' }}
39-
run: exit 1
43+
run: exit 1

0 commit comments

Comments
 (0)