-
Notifications
You must be signed in to change notification settings - Fork 23
100 lines (85 loc) · 2.98 KB
/
github-pages-pr-preview.yaml
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Deploy Sandbox PR Preview to GitHub Pages
on:
pull_request:
types:
- opened
- reopened
- synchronize
# Ensure previews are cleaned up when PR is closed
- closed
# TODO: Update branch name to beta when needed
branches:
- alpha
concurrency:
group: sandbox-pr-preview-${{ github.ref }}
cancel-in-progress: true
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
pull-requests: write
jobs:
deploy-preview:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Remove sandbox preview comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
delete: true
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }}
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build Sandbox
env:
# Tell the script to use the sandbox directory
USE_SANDBOX: true
run: yarn sandbox:build
# - name: Deploy Sandbox PR Preview to GitHub Pages
# id: pr-preview
# uses: rossjrw/pr-preview-action@v1
# env:
# GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }}
# with:
# source-dir: ./sandbox/dist
# preview-branch: ${{ github.head_ref || github.ref_name }}
# umbrella-dir: pr-preview
# token: ${{ secrets.KONGPONENTS_BOT_PAT }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
name: sandbox-assets
# Upload sandbox/dist directory
path: ./sandbox/dist
- name: Generate target folder
id: target-folder
run: |
echo "target-folder=pr-preview/pr-${{ github.event.number }}" >> $GITHUB_OUTPUT
# TODO: Only run when PR is created; create separate step for when PR is closed to remove pr folder
- name: Deploy Sandbox PR Preview to GitHub Pages
id: pr-preview
uses: JamesIves/github-pages-deploy-action@v4
with:
# TODO: Update branch name to beta when needed
branch: ${{ github.head_ref || github.ref_name }}
folder: sandbox-assets # The artifact name
target-folder: ${{ steps.target-folder.outputs.target-folder }}
clean-exclude: pr-preview/ # Do not remove other PR preview builds
force: false
token: ${{ secrets.KONGPONENTS_BOT_PAT }}
- name: Provide sandbox preview link
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
message: |
## Sandbox Deploy Preview
https://kong.github.io/kongponents/${{ steps.target-folder.outputs.target-folder }}/
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }}