diff --git a/.github/workflows/pull-request-preview.yml b/.github/workflows/pull-request-preview.yml new file mode 100644 index 0000000..12cbc6c --- /dev/null +++ b/.github/workflows/pull-request-preview.yml @@ -0,0 +1,44 @@ +on: pull_request +name: pull request preview + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + pull-requests: write + + steps: + - name: checkout + uses: actions/checkout@v4 + - name: setup PNPM + uses: pnpm/action-setup@v4 + with: + version: latest + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: install dependencies + run: pnpm i + - name: build page + run: pnpm build + + - name: publish to cloudflare pages + id: cloudflare-publish + uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: rosebud + directory: dist + branch: pull-${{ github.event.number }} + + - name: add link in footer + uses: devindford/Append_PR_Comment@v1.1.3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + body-template: | + --- + [preview this pull request!](${{ steps.cloudflare-publish.outputs.url }})