Skip to content

Commit

Permalink
NOISSUE - Use yet another alternative to grab PR ID
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Zanini <[email protected]>
  • Loading branch information
ricardozanini committed Mar 8, 2024
1 parent 396880b commit b91bc7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pr-preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ jobs:
- name: Install dependencies and build
run: npm run local-install-build

- name: Store PR id
if: github.event_name == 'pull_request'
run: |
echo ${{ github.event.number }} > ./build/site/pr-id.txt
- name: Publishing directory for PR preview
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/pr-preview-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ 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
Expand All @@ -47,20 +40,26 @@ jobs:
run-id: ${{ github.event.workflow_run.id }}
path: ./build/site

- name: Store PR id as variable
id: pr
run: |
echo "id=$(<./build/site/pr-id.txt)" >> $GITHUB_OUTPUT
rm -f pr-id.txt
- name: Publish to Surge for preview
id: deploy
run: npx surge ./build/site --domain https://sonataflow-docs-preview-pr-${{ env.PR_NUMBER }}.surge.sh --token ${{ secrets.SURGE_LOCAL_TOKEN }}
run: npx surge ./build/site --domain https://sonataflow-docs-preview-pr-${{ steps.pr.outputs.id }}.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-${{ env.PR_NUMBER }}.surge.sh
🎊 PR Preview ${{ github.sha }} has been successfully built and deployed. See the documentation preview: https://sonataflow-docs-preview-pr-${{ steps.pr.outputs.id }}.surge.sh
<!-- Sticky Pull Request Comment -->
body-include: "<!-- Sticky Pull Request Comment -->"
number: ${{ env.PR_NUMBER }}
number: ${{ steps.pr.outputs.id }}
emojis: "heart"

- name: Update PR status comment on failure
Expand All @@ -73,5 +72,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: ${{ env.PR_NUMBER }}
number: ${{ steps.pr.outputs.id }}
emojis: "confused"

0 comments on commit b91bc7d

Please sign in to comment.