Skip to content

Commit 6e904e4

Browse files
committed
added "update status to PR" step for gh action bot
1 parent f410705 commit 6e904e4

File tree

1 file changed

+20
-40
lines changed

1 file changed

+20
-40
lines changed
Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
name: Show generated code in PR
1+
name: Preview Generated Code
2+
3+
permissions:
4+
contents: write
5+
statuses: write
26

37
on:
48
pull_request:
@@ -10,16 +14,15 @@ on:
1014
- ready_for_review
1115

1216
jobs:
13-
build:
17+
build_preview_generated_code:
18+
name: Build Preview of Generated Code
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
1422
runs-on: ubuntu-latest
1523
env:
1624
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1725
steps:
18-
- name: Cancel Previous Runs
19-
uses: styfle/[email protected]
20-
with:
21-
access_token: ${{ github.token }}
22-
2326
- name: Checkout repository
2427
uses: actions/checkout@v4
2528

@@ -39,7 +42,7 @@ jobs:
3942

4043
- name: Check for changes in generated sources
4144
id: git-diff
42-
run: echo "::set-output name=changed::$(if git diff --quiet './core/generated-sources' './docs/StardustDocs/snippets' './docs/StardustDocs/topics'; then echo 'false'; else echo 'true'; fi)"
45+
run: echo "changed=$(if git diff --quiet './core/generated-sources' './docs/StardustDocs/snippets' './docs/StardustDocs/topics'; then echo 'false'; else echo 'true'; fi)" >> $GITHUB_OUTPUT
4346

4447
- name: Commit and push if changes
4548
id: git-commit
@@ -49,44 +52,21 @@ jobs:
4952
git add './core/generated-sources' './docs/StardustDocs/snippets' './docs/StardustDocs/topics'
5053
git commit -m "Update generated sources with recent changes"
5154
git push origin generated-sources/docs-update-${{ github.run_number }}
52-
echo "::set-output name=commit::$(git rev-parse HEAD)"
53-
54-
- name: Remove old comments
55-
uses: actions/github-script@v7
56-
if: steps.git-diff.outputs.changed == 'true'
57-
with:
58-
# language=js
59-
script: |
60-
const issue_number = context.issue.number;
61-
const {owner, repo} = context.repo;
62-
63-
const comments = await github.rest.issues.listComments({
64-
issue_number,
65-
owner,
66-
repo,
67-
});
68-
69-
const botComments = comments.data.filter(
70-
(comment) => comment.user.login === 'github-actions[bot]'
71-
);
72-
73-
for (const comment of botComments) {
74-
await github.rest.issues.deleteComment({
75-
comment_id: comment.id,
76-
owner,
77-
repo,
78-
});
79-
}
55+
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
8056
81-
- name: Add comment to PR
57+
- name: Update status to PR
8258
uses: actions/github-script@v7
8359
if: steps.git-diff.outputs.changed == 'true'
8460
with:
8561
# language=js
8662
script: |
87-
github.rest.issues.createComment({
88-
issue_number: context.issue.number,
63+
await github.rest.repos.createCommitStatus({
8964
owner: context.repo.owner,
9065
repo: context.repo.repo,
91-
body: "Generated sources will be updated after merging this PR.\nPlease inspect the changes in [here](https://github.com/${{ github.repository }}/commit/${{ steps.git-commit.outputs.commit }}).",
66+
sha: context.payload.pull_request.head.sha,
67+
state: "success",
68+
target_url: "https://github.com/${{ github.repository }}/commit/${{ steps.git-commit.outputs.commit }}",
69+
context: "Generated sources will change, merging this PR",
70+
description: "Check 'Details' to inspect changes ->"
9271
});
72+

0 commit comments

Comments
 (0)