|
| 1 | +name: PR Preview |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: [ "Build PR Preview" ] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + |
| 9 | +defaults: |
| 10 | + run: |
| 11 | + shell: bash |
| 12 | + |
| 13 | +jobs: |
| 14 | + preview: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' |
| 17 | + permissions: |
| 18 | + pull-requests: write # Required to update PR status comment |
| 19 | + steps: |
| 20 | + - name: Store PR id as variable |
| 21 | + id: pr |
| 22 | + run: | |
| 23 | + echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT |
| 24 | + rm -f pr-id.txt |
| 25 | +
|
| 26 | + - name: Download blog artifact |
| 27 | + uses: actions/download-artifact@v4 |
| 28 | + with: |
| 29 | + name: blog |
| 30 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + run-id: ${{ github.event.workflow_run.id }} |
| 32 | + |
| 33 | + - name: Publishing blog to gh-pages |
| 34 | + id: deploy-blog |
| 35 | + run: npx surge ./ --domain https://netobserv-io-blog-${{ steps.pr.outputs.id }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }} |
| 36 | + |
| 37 | + - name: Update PR status comment on success |
| 38 | + uses: quarkusio/action-helpers@main |
| 39 | + with: |
| 40 | + action: maintain-one-comment |
| 41 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + pr-number: ${{ steps.pr.outputs.id }} |
| 43 | + body: | |
| 44 | + 🚀 PR Preview for **blog** ${{ github.sha }} has been successfully built! |
| 45 | + * https://netobserv-io-blog-${{ steps.pr.outputs.id }}-preview.surge.sh |
| 46 | + body-marker: <!-- Preview status comment marker --> |
| 47 | + |
| 48 | + - name: Update PR status comment on failure |
| 49 | + uses: quarkusio/action-helpers@main |
| 50 | + if: ${{ failure() }} |
| 51 | + with: |
| 52 | + action: maintain-one-comment |
| 53 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + pr-number: ${{ steps.pr.outputs.id }} |
| 55 | + body: | |
| 56 | + 😭 Deploy PR Preview failed. |
| 57 | + body-marker: <!-- Preview status comment marker --> |
0 commit comments