-
-
Notifications
You must be signed in to change notification settings - Fork 24
71 lines (56 loc) · 2.23 KB
/
pr-comment.yml
File metadata and controls
71 lines (56 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: PR Comment
on:
workflow_run:
workflows: ["PR Check"]
types:
- completed
permissions:
pull-requests: write
jobs:
comment:
name: 'Comment on PR'
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: 💬 Comment on PR with APK Link
uses: actions/github-script@v7
with:
script: |
const workflowRun = context.payload.workflow_run;
const runId = workflowRun.id;
const repo = context.repo;
// Get the PR number from the workflow run
const prNumber = workflowRun.pull_requests[0]?.number;
if (!prNumber) {
console.log('No PR number found, skipping comment');
return;
}
// Check if we already commented on this PR for this run
const comments = await github.rest.issues.listComments({
owner: repo.owner,
repo: repo.repo,
issue_number: prNumber
});
const existingComment = comments.data.find(comment =>
comment.body.includes(`actions/runs/${runId}`) &&
comment.body.includes('APK Build Complete')
);
if (existingComment) {
console.log('Comment already exists for this run, skipping');
return;
}
const comment = `## 📱 APK Build Complete!
Your debug APK has been built successfully and is ready for testing.
### 📥 Download APK
[Download app-debug.apk](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})
**Note:** Click the link above, scroll down to the "Artifacts" section, and download the \`app-debug\` artifact.
**Retention:** This artifact will be available for 3 days.`;
await github.rest.issues.createComment({
owner: repo.owner,
repo: repo.repo,
issue_number: prNumber,
body: comment
});
console.log(`Comment added to PR #${prNumber}`);