1
- name : Show generated code in PR
1
+ name : Preview Generated Code
2
+
3
+ permissions :
4
+ contents : write
5
+ statuses : write
2
6
3
7
on :
4
8
pull_request :
10
14
- ready_for_review
11
15
12
16
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
14
22
runs-on : ubuntu-latest
15
23
env :
16
24
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
17
25
steps :
18
- - name : Cancel Previous Runs
19
-
20
- with :
21
- access_token : ${{ github.token }}
22
-
23
26
- name : Checkout repository
24
27
uses : actions/checkout@v4
25
28
39
42
40
43
- name : Check for changes in generated sources
41
44
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
43
46
44
47
- name : Commit and push if changes
45
48
id : git-commit
@@ -49,44 +52,21 @@ jobs:
49
52
git add './core/generated-sources' './docs/StardustDocs/snippets' './docs/StardustDocs/topics'
50
53
git commit -m "Update generated sources with recent changes"
51
54
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
80
56
81
- - name : Add comment to PR
57
+ - name : Update status to PR
82
58
uses : actions/github-script@v7
83
59
if : steps.git-diff.outputs.changed == 'true'
84
60
with :
85
61
# language=js
86
62
script : |
87
- github.rest.issues.createComment({
88
- issue_number: context.issue.number,
63
+ await github.rest.repos.createCommitStatus({
89
64
owner: context.repo.owner,
90
65
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 ->"
92
71
});
72
+
0 commit comments