Preview PR #204
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
name: Preview PR | |
# read-write repo token | |
# access to secrets | |
on: | |
workflow_run: | |
workflows: ["Receive PR"] | |
types: | |
- completed | |
jobs: | |
preview-pr: | |
runs-on: ubuntu-latest | |
if: > | |
${{ github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: Install surge | |
run: npm --global install surge | |
- name: Download artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
workflow: receive_pr.yml | |
run_id: ${{ github.event.workflow_run.id }} | |
name: site | |
path: ./artifact | |
- name: 'Get PR number' | |
id: get-pr-number | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
var fs = require('fs'); | |
return Number(fs.readFileSync('./artifact/pr/number')); | |
- name: Deploy PR preview | |
run: | | |
surge ./artifact/_site ${{ github.repository_owner}}-riot-os-org-preview-${{ steps.get-pr-number.outputs.result }}.surge.sh --token ${{ secrets.SURGE_TOKEN }} | |
- name: Comment URL | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
number: ${{ steps.get-pr-number.outputs.result }} | |
message: | | |
🚀 PR preview deployed to <https://${{ github.repository_owner}}-riot-os-org-preview-${{ steps.get-pr-number.outputs.result }}.surge.sh> |