Publish PR preview #356
This file contains 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
on: | |
workflow_run: | |
workflows: ["Build PR preview"] | |
types: [completed] | |
name: Publish PR preview | |
jobs: | |
get-pr-number: | |
# We need the PR number to generate the branch URL for Cloudflare Pages, but GitHub doesn't seem to have a way to derive the PR number (or receive any input at all) from the triggering workflow, so we use artifacts instead. | |
name: Get PR Number | |
runs-on: ubuntu-latest | |
outputs: | |
pr-number: ${{ steps.output-pr-number.outputs.pr-number }} | |
permissions: | |
actions: read | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Download Artifact from triggering workflow | |
env: | |
RUN_ID: ${{ github.event.workflow_run.id }} | |
GITHUB_TOKEN: ${{ secrets.COZY_PAT }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: pr_number | |
path: pr | |
run-id: ${{ env.RUN_ID }} | |
github-token: ${{ env.GITHUB_TOKEN }} | |
- name: Output PR Number | |
id: output-pr-number | |
run: echo "pr-number=$(cat ./pr/pr_number)" >> "$GITHUB_OUTPUT" | |
publish-preview: | |
uses: ./.github/workflows/publish-website.yaml | |
needs: get-pr-number | |
with: | |
branch: preview-${{ needs.get-pr-number.outputs.pr-number }} | |
run-id: ${{ github.event.workflow_run.id }} | |
secrets: inherit |