Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO-ISSUE - Use yet another alternative to grab PR ID #569

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading