Surge.sh PR Preview #44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Surge.sh PR Preview | |
on: | |
workflow_run: | |
workflows: [ "Build PR Preview" ] | |
types: | |
- completed | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
preview: | |
runs-on: ubuntu-latest | |
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' | |
permissions: | |
pull-requests: write # Required to update PR status comment | |
steps: | |
- name: Download blog artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: blog | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
run-id: ${{ github.event.workflow_run.id }} | |
- name: Retrieve PR id | |
id: pr | |
run: | | |
echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT | |
rm -f .pr-id | |
- name: Publishing blog to gh-pages | |
id: deploy-blog | |
run: npx surge ./ --domain https://netobserv-io-blog-${{ steps.pr.outputs.id }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }} | |
- name: Update PR status comment on success | |
uses: quarkusio/action-helpers@main | |
with: | |
action: maintain-one-comment | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
pr-number: ${{ steps.pr.outputs.id }} | |
body: | | |
🚀 PR Preview for netobserv.io has been successfully deployed! | |
It's available at https://netobserv-io-blog-${{ steps.pr.outputs.id }}-preview.surge.sh and will be removed when the PR closes. | |
body-marker: <!-- Preview status comment marker --> | |
- name: Update PR status comment on failure | |
uses: quarkusio/action-helpers@main | |
if: ${{ failure() }} | |
with: | |
action: maintain-one-comment | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
pr-number: ${{ steps.pr.outputs.id }} | |
body: | | |
😭 Deploy PR Preview failed. | |
body-marker: <!-- Preview status comment marker --> |