Skip to content

Commit 201fa74

Browse files
committed
Drop a comment
1 parent 4f8f9c8 commit 201fa74

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,47 @@ jobs:
4949
5050
- name: Upload docs
5151
uses: actions/upload-artifact@v4
52+
id: docs-upload
5253
with:
5354
name: docs
5455
path: doc/
56+
overwrite: true
57+
58+
- name: Build update
59+
uses: actions/github-script@v7
60+
if: github.event_name == 'pull_request'
61+
env:
62+
ARTIFACT_ID: ${{ steps.docs-upload.outputs.artifact-id }}
63+
with:
64+
script: |
65+
const artifactUrl = '$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts/$ARTIFACT_ID';
66+
const commentBody = `<!-- build-artifact-comment -->📦 Build artifacts are ready: ${artifactUrl}`;
67+
68+
const comments = await github.rest.issues.listComments({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
issue_number: context.issue.number,
72+
});
73+
74+
const botComment = comments.data.find(comment =>
75+
comment.body.includes('<!-- build-artifact-comment -->')
76+
);
77+
78+
if (botComment) {
79+
await github.rest.issues.updateComment({
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
comment_id: botComment.id,
83+
body: commentBody
84+
});
85+
} else {
86+
await github.rest.issues.createComment({
87+
owner: context.repo.owner,
88+
repo: context.repo.repo,
89+
issue_number: context.issue.number,
90+
body: commentBody
91+
});
92+
}
5593
5694
# Test Elixir
5795
- run: mix format --check-formatted

0 commit comments

Comments
 (0)