Skip to content

Commit

Permalink
NO-ISSUE - Try to fix PR id not found in github event (#566)
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Zanini <[email protected]>
  • Loading branch information
ricardozanini authored Mar 7, 2024
1 parent 42c2e31 commit d6eda9f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/pr-preview-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ jobs:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Get PR number
id: get_pr_number
run: |
PR_URL=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ${{ github.event.workflow_run.url }}/pull_requests | jq -r '.pull_requests[0].url')
PR_NUMBER=$(basename $PR_URL)
echo "PR number: $PR_NUMBER"
shell: bash

- name: Download PR Artifact
uses: actions/download-artifact@v4
with:
Expand All @@ -41,18 +49,18 @@ jobs:

- name: Publish to Surge for preview
id: deploy
run: npx surge ./build/site --domain https://sonataflow-docs-preview-pr-${{ github.event.workflow_run.pull_requests[0].number }}.surge.sh --token ${{ secrets.SURGE_LOCAL_TOKEN }}
run: npx surge ./build/site --domain https://sonataflow-docs-preview-pr-${{ env.PR_NUMBER }}.surge.sh --token ${{ secrets.SURGE_LOCAL_TOKEN }}

- name: Update PR status comment on success
if: success()
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🎊 PR Preview ${{ github.sha }} has been successfully built and deployed. See the documentation preview: https://sonataflow-docs-preview-pr-${{ github.event.workflow_run.pull_requests[0].number }}.surge.sh
🎊 PR Preview ${{ github.sha }} has been successfully built and deployed. See the documentation preview: https://sonataflow-docs-preview-pr-${{ env.PR_NUMBER }}.surge.sh
<!-- Sticky Pull Request Comment -->
body-include: "<!-- Sticky Pull Request Comment -->"
number: ${{ github.event.workflow_run.pull_requests[0].number }}
number: ${{ env.PR_NUMBER }}
emojis: "heart"

- name: Update PR status comment on failure
Expand All @@ -65,5 +73,5 @@ jobs:
<img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
<!-- Sticky Pull Request Comment -->
body-include: "<!-- Sticky Pull Request Comment -->"
number: ${{ github.event.workflow_run.pull_requests[0].number }}
number: ${{ env.PR_NUMBER }}
emojis: "confused"

0 comments on commit d6eda9f

Please sign in to comment.