2022-09-07 10:16:44 +02:00
|
|
|
name: Deploy PR to Netlify
|
2022-12-14 06:17:10 +01:00
|
|
|
|
2021-11-14 08:24:17 +01:00
|
|
|
on:
|
2022-03-15 12:34:14 +01:00
|
|
|
workflow_run:
|
2022-03-15 12:49:18 +01:00
|
|
|
workflows: ["Build pull request"]
|
2022-09-07 10:16:44 +02:00
|
|
|
types: [completed]
|
2022-12-14 06:17:10 +01:00
|
|
|
|
2021-11-14 08:24:17 +01:00
|
|
|
jobs:
|
2022-09-07 10:16:44 +02:00
|
|
|
deploy-pull-request:
|
2022-12-14 06:17:10 +01:00
|
|
|
name: Deploy pull request
|
2022-09-07 10:16:44 +02:00
|
|
|
runs-on: ubuntu-latest
|
2022-05-26 16:47:41 +02:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
pull-requests: write
|
2022-09-07 10:16:44 +02:00
|
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
2022-03-15 12:34:14 +01:00
|
|
|
steps:
|
2022-09-07 10:16:44 +02:00
|
|
|
- name: Download pr number
|
2023-06-12 13:38:53 +02:00
|
|
|
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615
|
2022-03-15 12:34:14 +01:00
|
|
|
with:
|
2022-09-07 10:16:44 +02:00
|
|
|
workflow: ${{ github.event.workflow.id }}
|
|
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
|
|
name: pr
|
|
|
|
- name: Output pr number
|
|
|
|
id: pr
|
2022-11-09 13:46:14 +01:00
|
|
|
run: echo "id=$(<pr.txt)" >> $GITHUB_OUTPUT
|
2022-09-07 10:16:44 +02:00
|
|
|
- name: Download artifact
|
2023-06-12 13:38:53 +02:00
|
|
|
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615
|
2022-03-15 12:34:14 +01:00
|
|
|
with:
|
2022-09-07 10:16:44 +02:00
|
|
|
workflow: ${{ github.event.workflow.id }}
|
|
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
|
|
name: preview
|
|
|
|
path: dist
|
2022-03-15 12:34:14 +01:00
|
|
|
- name: Deploy to Netlify
|
|
|
|
id: netlify
|
2022-12-09 12:22:04 +01:00
|
|
|
uses: nwtgck/actions-netlify@5da65c9f74c7961c5501a3ba329b8d0912f39c03
|
2022-03-15 12:34:14 +01:00
|
|
|
with:
|
|
|
|
publish-dir: dist
|
2022-09-07 10:16:44 +02:00
|
|
|
deploy-message: "Deploy PR ${{ steps.pr.outputs.id }}"
|
|
|
|
alias: ${{ steps.pr.outputs.id }}
|
2022-03-15 12:34:14 +01:00
|
|
|
# These don't work because we're in workflow_run
|
|
|
|
enable-pull-request-comment: false
|
|
|
|
enable-commit-comment: false
|
|
|
|
env:
|
|
|
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
2022-12-14 06:17:10 +01:00
|
|
|
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_PR_CINNY }}
|
2022-03-15 12:34:14 +01:00
|
|
|
timeout-minutes: 1
|
2022-12-09 08:35:02 +01:00
|
|
|
- name: Comment preview on PR
|
2023-06-12 13:36:13 +02:00
|
|
|
uses: thollander/actions-comment-pull-request@632cf9ce90574d125be56b5f3405cda41a84e2fd
|
2022-03-15 12:34:14 +01:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
2022-12-09 08:35:02 +01:00
|
|
|
pr_number: ${{ steps.pr.outputs.id }}
|
|
|
|
comment_tag: ${{ steps.pr.outputs.id }}
|
|
|
|
message: |
|
2022-03-15 12:34:14 +01:00
|
|
|
Preview: ${{ steps.netlify.outputs.deploy-url }}
|
2022-09-07 10:16:44 +02:00
|
|
|
⚠️ Exercise caution. Use test accounts. ⚠️
|