Skip to content

Adjusted Workflow Order for Artifact Access #6200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions .github/workflows/android-ci-comment.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Android CI Comment

on: [pull_request_target]
on:
workflow_run:
workflows: ["Android CI"]
types: [completed]
branches: [main]

permissions:
issues: write
Expand All @@ -9,24 +13,25 @@ jobs:
comment:
name: Comment on PR with APK links
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout base branch
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}

ref: ${{ github.event.workflow_run.head_branch }}
- name: Download Run ID Artifact
uses: actions/download-artifact@v4
with:
name: run-id
run-id: ${{ github.event.workflow_run.id }}

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

- name: Comment on PR with APK download links
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/github-script@v6
with:
script: |
Expand All @@ -41,6 +46,13 @@ jobs:
throw new Error('Run ID not found.');
}

// Get the PR number from the workflow_run event
const prNumber = ${{ github.event.workflow_run.pull_requests[0].number }};
if (!prNumber) {
console.log('No PR number found in workflow_run event.');
return;
}

const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down Expand Up @@ -71,7 +83,7 @@ jobs:
`;

await github.rest.issues.createComment({
issue_number: context.issue.number,
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
Expand Down
Loading