mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2026-04-29 21:51:49 +00:00
Use alternative way to get PR number
This commit is contained in:
parent
daf0b1343a
commit
dd4634ef6f
1 changed files with 26 additions and 17 deletions
43
.github/workflows/update-pr-artifacts.yml
vendored
43
.github/workflows/update-pr-artifacts.yml
vendored
|
|
@ -12,22 +12,31 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Get PR Number
|
- name: Get PR Number
|
||||||
id: pr-number
|
id: pr-number
|
||||||
env:
|
uses: actions/github-script@v7
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
with:
|
||||||
run: |
|
result-encoding: string
|
||||||
# Get list of PR's associated to the commit that triggered the workflow run
|
script: |
|
||||||
prs=$(gh api -H "Accept: application/vnd.github+json" "/repos/${{ github.event.pull_request.head.repo.full_name }}/commits/${{ github.event.workflow_run.head_sha }}/pulls")
|
const { owner, repo } = context.repo;
|
||||||
|
|
||||||
# Find the PR against the current repo
|
const findPRNumber = async () => {
|
||||||
pr_number=$(echo "$prs" | jq -r '.[] | select(.base.repo.full_name == "${{ github.repository }}") | .number' | head -n1)
|
const pulls = await github.rest.pulls.list({ owner, repo });
|
||||||
|
for await (const { data } of github.paginate.iterator(pulls)) {
|
||||||
if [ -z "$pr_number" ]; then
|
for (const pull of data) {
|
||||||
echo "No pull request found for this workflow run"
|
if (pull.head.sha === '${{ github.event.workflow_run.head_sha }}' && pull.user.id === '${{ github.event.sender.id }}') {
|
||||||
exit 1
|
return pull.number;
|
||||||
else
|
}
|
||||||
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
|
}
|
||||||
echo "PR number: $pr_number"
|
}
|
||||||
fi
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const prNumber = await findPRNumber();
|
||||||
|
if (!prNumber) {
|
||||||
|
core.error(`No matching pull request found`);
|
||||||
|
} else {
|
||||||
|
return prNumber;
|
||||||
|
}
|
||||||
- name: Create Artifacts Content
|
- name: Create Artifacts Content
|
||||||
id: artifacts-content
|
id: artifacts-content
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
|
|
@ -51,5 +60,5 @@ jobs:
|
||||||
with:
|
with:
|
||||||
section-name: 'artifacts'
|
section-name: 'artifacts'
|
||||||
repo-token: '${{ secrets.GITHUB_TOKEN }}'
|
repo-token: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
pr-number: ${{ steps.pr-number.outputs.pr_number }}
|
pr-number: ${{ steps.pr-number.outputs.result }}
|
||||||
section-value: '${{ steps.artifacts-content.outputs.result }}'
|
section-value: '${{ steps.artifacts-content.outputs.result }}'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue