-
Notifications
You must be signed in to change notification settings - Fork 6
60 lines (57 loc) · 1.97 KB
/
fork-preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Preview site from Fork
on:
workflow_call:
secrets:
token: # SURGE_TOKEN
description: the token for deployment service
required: true
inputs:
domain:
description: the domain to use
required: true
type: string
jobs:
build:
runs-on: ubuntu-latest
name: Deploying to surge
steps:
- uses: actions/checkout@v2
- name: Download built site artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: fork-build.yml
run_id: ${{ github.event.workflow_run.id }}
name: site-artifacts
path: .
- name: Extract PR number
id: pr-number
run: echo "ACTIONS_PR_NUMBER=$(cat ./pr/NUMBER)" >> $GITHUB_OUTPUT
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Build PR preview url
id: pr-url
run: |
PR_URL="https://pr-${{ steps.pr-number.outputs.ACTIONS_PR_NUMBER }}-${{ inputs.domain }}"
echo "ACTIONS_PREVIEW_URL=${PR_URL}" >> $GITHUB_OUTPUT
- name: Install surge and deploy PR to surge
run: |
npm i -g surge
surge --project ./curr-repo/_site --domain ${{ steps.pr-url.outputs.ACTIONS_PREVIEW_URL }}
env:
SURGE_TOKEN: ${{ secrets.token }}
- name: Find existing PR preview link comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ steps.pr-number.outputs.ACTIONS_PR_NUMBER }}
body-includes: Your PR can be previewed
- name: Comment PR preview link in PR
if: ${{ steps.fc.outputs.comment-id == 0 }}
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ steps.pr-number.outputs.ACTIONS_PR_NUMBER }}
body: |
Thank you for submitting the Pull Request! :thumbsup:
Your PR can be previewed [here](${{ steps.pr-url.outputs.ACTIONS_PREVIEW_URL }})