File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 1111 description : ' PR number to deploy preview for'
1212 required : true
1313 type : number
14- run_id :
15- description : ' Run ID of the build workflow (from the PR checks)'
16- required : true
17- type : string
1814
1915permissions :
2016 contents : write
@@ -51,12 +47,27 @@ jobs:
5147 - name : Checkout
5248 uses : actions/checkout@v4
5349
50+ - name : Find latest run ID
51+ id : find-run
52+ env :
53+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54+ run : |
55+ BRANCH=$(gh pr view ${{ inputs.pr_number }} --json headRefName --jq .headRefName)
56+ echo "Found branch: $BRANCH"
57+ RUN_ID=$(gh run list --workflow "Publish Docs" --branch "$BRANCH" --event pull_request --status success --limit 1 --json databaseId --jq '.[0].databaseId')
58+ echo "Found run ID: $RUN_ID"
59+ if [ -z "$RUN_ID" ]; then
60+ echo "::error::No successful 'Publish Docs' run found for PR #${{ inputs.pr_number }} (branch: $BRANCH)"
61+ exit 1
62+ fi
63+ echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
64+
5465 - name : Download build artifact
5566 uses : actions/download-artifact@v4
5667 with :
5768 name : site
5869 path : site
59- run-id : ${{ inputs .run_id }}
70+ run-id : ${{ steps.find-run.outputs .run_id }}
6071 github-token : ${{ secrets.GITHUB_TOKEN }}
6172
6273 - name : Deploy PR Preview
You can’t perform that action at this time.
0 commit comments