Skip to content

Commit b292748

Browse files
Update android-ci-comment.yml (commons-app#6200)
1 parent fda87b7 commit b292748

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

.github/workflows/android-ci-comment.yml

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Android CI Comment
22

3-
on: [pull_request_target]
3+
on:
4+
workflow_run:
5+
workflows: ["Android CI"]
6+
types: [completed]
7+
branches: [main]
48

59
permissions:
610
issues: write
@@ -9,24 +13,25 @@ jobs:
913
comment:
1014
name: Comment on PR with APK links
1115
runs-on: ubuntu-latest
16+
if: github.event.workflow_run.conclusion == 'success'
1217
steps:
1318
- name: Checkout base branch
1419
uses: actions/checkout@v3
1520
with:
16-
ref: ${{ github.base_ref }}
17-
21+
ref: ${{ github.event.workflow_run.head_branch }}
1822
- name: Download Run ID Artifact
1923
uses: actions/download-artifact@v4
2024
with:
2125
name: run-id
26+
run-id: ${{ github.event.workflow_run.id }}
2227

2328
- name: Read Run ID
2429
id: read-run-id
2530
run: echo "RUN_ID=$(cat run_id.txt)" >> $GITHUB_ENV
2631

2732
- name: Comment on PR with APK download links
2833
env:
29-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3035
uses: actions/github-script@v6
3136
with:
3237
script: |
@@ -41,6 +46,13 @@ jobs:
4146
throw new Error('Run ID not found.');
4247
}
4348
49+
// Get the PR number from the workflow_run event
50+
const prNumber = ${{ github.event.workflow_run.pull_requests[0].number }};
51+
if (!prNumber) {
52+
console.log('No PR number found in workflow_run event.');
53+
return;
54+
}
55+
4456
const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({
4557
owner: context.repo.owner,
4658
repo: context.repo.repo,
@@ -71,7 +83,7 @@ jobs:
7183
`;
7284
7385
await github.rest.issues.createComment({
74-
issue_number: context.issue.number,
86+
issue_number: prNumber,
7587
owner: context.repo.owner,
7688
repo: context.repo.repo,
7789
body: commentBody

0 commit comments

Comments
 (0)