Skip to content

Preview PR

Preview PR #218

Workflow file for this run

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@v4
with:
node-version: '14'
- name: Install surge
run: npm --global install surge
- name: Download artifact
uses: dawidd6/action-download-artifact@v6
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@v7
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>