-
Notifications
You must be signed in to change notification settings - Fork 36
86 lines (80 loc) · 2.66 KB
/
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Deploy PR previews
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- closed
concurrency: preview-${{ github.head_ref }}
defaults:
run:
shell: bash
jobs:
build-preview:
if: github.event_name == 'pull_request_target' && github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- name: Use Node.js
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
node-version: '18'
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Build
run: |
npm install
npm run build
- name: Upload artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: "site"
path: ./public
deploy-preview:
needs: build-preview
runs-on: ubuntu-latest
permissions:
pull-requests: write
environment:
name: pull-request-preview
url: ${{ steps.deployment.outputs.deployment-url }}
steps:
# checkout required for pr-preview-action to succeed,
# while the content will not be used
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Download the preview page
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: "site"
path: ./public
- uses: rossjrw/pr-preview-action@4668d7cb417ce7067b0b59bc152b1ae1513010de # v1.4.6
id: deployment
with:
source-dir: ./public
preview-branch: previews
umbrella-dir: pr-previews
deploy-repository: eclipse-langium/langium-previews
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
action: auto
# remove the preview page when the PR got closed
remove-preview:
if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
# checkout required for pr-preview-action to succeed,
# while the content will not be used
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: rossjrw/pr-preview-action@4668d7cb417ce7067b0b59bc152b1ae1513010de # v1.4.6
id: deployment
with:
preview-branch: previews
umbrella-dir: pr-previews
deploy-repository: eclipse-langium/langium-previews
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
action: auto