2022-09-07 11:16:44 +03:00
|
|
|
name: Deploy PR to Netlify
|
2021-11-14 09:24:17 +02:00
|
|
|
on:
|
2022-03-15 13:34:14 +02:00
|
|
|
workflow_run:
|
2022-03-15 13:49:18 +02:00
|
|
|
workflows: ["Build pull request"]
|
2022-09-07 11:16:44 +03:00
|
|
|
types: [completed]
|
2021-11-14 09:24:17 +02:00
|
|
|
jobs:
|
2022-09-07 11:16:44 +03:00
|
|
|
deploy-pull-request:
|
|
|
|
name: 'Deploy pull request'
|
|
|
|
runs-on: ubuntu-latest
|
2022-05-26 17:47:41 +03:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
pull-requests: write
|
2022-09-07 11:16:44 +03:00
|
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
2022-03-15 13:34:14 +02:00
|
|
|
steps:
|
2022-09-07 11:16:44 +03:00
|
|
|
- name: Download pr number
|
2022-10-15 12:46:49 +03:00
|
|
|
uses: dawidd6/action-download-artifact@46b4ae883bf0726f5949d025d31cb62c7a5ac70c
|
2022-03-15 13:34:14 +02:00
|
|
|
with:
|
2022-09-07 11:16:44 +03:00
|
|
|
workflow: ${{ github.event.workflow.id }}
|
|
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
|
|
name: pr
|
|
|
|
- name: Output pr number
|
|
|
|
id: pr
|
|
|
|
run: echo "::set-output name=id::$(<pr.txt)"
|
|
|
|
- name: Download artifact
|
2022-10-15 12:46:49 +03:00
|
|
|
uses: dawidd6/action-download-artifact@46b4ae883bf0726f5949d025d31cb62c7a5ac70c
|
2022-03-15 13:34:14 +02:00
|
|
|
with:
|
2022-09-07 11:16:44 +03:00
|
|
|
workflow: ${{ github.event.workflow.id }}
|
|
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
|
|
name: preview
|
|
|
|
path: dist
|
2022-03-15 13:34:14 +02:00
|
|
|
- name: Deploy to Netlify
|
|
|
|
id: netlify
|
2022-10-15 12:46:01 +03:00
|
|
|
uses: nwtgck/actions-netlify@ac1cb16858bada08a9c71a81240a85cfc3f72913
|
2022-03-15 13:34:14 +02:00
|
|
|
with:
|
|
|
|
publish-dir: dist
|
2022-09-07 11:16:44 +03:00
|
|
|
deploy-message: "Deploy PR ${{ steps.pr.outputs.id }}"
|
|
|
|
alias: ${{ steps.pr.outputs.id }}
|
2022-03-15 13:34:14 +02: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 }}
|
|
|
|
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE3_ID }}
|
|
|
|
timeout-minutes: 1
|
|
|
|
- name: Edit PR Description
|
2022-05-01 10:53:42 +03:00
|
|
|
uses: Beakyn/gha-comment-pull-request@2167a7aee24f9e61ce76a23039f322e49a990409
|
2022-03-15 13:34:14 +02:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
2022-09-07 11:16:44 +03:00
|
|
|
pull-request-number: ${{ steps.pr.outputs.id }}
|
2022-03-15 13:34:14 +02:00
|
|
|
description-message: |
|
|
|
|
Preview: ${{ steps.netlify.outputs.deploy-url }}
|
2022-09-07 11:16:44 +03:00
|
|
|
⚠️ Exercise caution. Use test accounts. ⚠️
|