Skip to content

Commit 279bd97

Browse files
committed
Store/retrieve PR id
1 parent ae040fa commit 279bd97

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

.github/workflows/build-pr-preview.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
github-pages: 'false'
1919
setup-java: 'false'
2020

21+
- name: Store PR id
22+
run: |
23+
echo ${{ github.event.number }} > ./target/roq/.pr-id
24+
2125
- name: Publishing blog
2226
uses: actions/upload-artifact@v4
2327
with:

.github/workflows/surge-deploy-preview.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,32 @@ jobs:
1717
permissions:
1818
pull-requests: write # Required to update PR status comment
1919
steps:
20-
- name: Dump GitHub context
21-
env:
22-
GITHUB_CONTEXT: ${{ toJson(github) }}
23-
run: echo "$GITHUB_CONTEXT"
24-
2520
- name: Download blog artifact
2621
uses: actions/download-artifact@v4
2722
with:
2823
name: blog
2924
github-token: ${{ secrets.GITHUB_TOKEN }}
3025
run-id: ${{ github.event.workflow_run.id }}
3126

27+
- name: Retrieve PR id
28+
id: pr
29+
run: |
30+
echo "id=$(<.pr-id)" >> $GITHUB_OUTPUT
31+
rm -f .pr-id
32+
3233
- name: Publishing blog to gh-pages
3334
id: deploy-blog
34-
run: npx surge ./ --domain https://netobserv-io-blog-${{ github.event.workflow_run.pull_requests[0].number }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }}
35+
run: npx surge ./ --domain https://netobserv-io-blog-${{ steps.pr.outputs.id }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }}
3536

3637
- name: Update PR status comment on success
3738
uses: quarkusio/action-helpers@main
3839
with:
3940
action: maintain-one-comment
4041
github-token: ${{ secrets.GITHUB_TOKEN }}
41-
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
42+
pr-number: ${{ steps.pr.outputs.id }}
4243
body: |
4344
🚀 PR Preview for **blog** ${{ github.sha }} has been successfully built!
44-
* https://netobserv-io-blog-${{ github.event.workflow_run.pull_requests[0].number }}-preview.surge.sh
45+
* https://netobserv-io-blog-${{ steps.pr.outputs.id }}-preview.surge.sh
4546
body-marker: <!-- Preview status comment marker -->
4647

4748
- name: Update PR status comment on failure
@@ -50,7 +51,7 @@ jobs:
5051
with:
5152
action: maintain-one-comment
5253
github-token: ${{ secrets.GITHUB_TOKEN }}
53-
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
54+
pr-number: ${{ steps.pr.outputs.id }}
5455
body: |
5556
😭 Deploy PR Preview failed.
5657
body-marker: <!-- Preview status comment marker -->

0 commit comments

Comments
 (0)