-
Notifications
You must be signed in to change notification settings - Fork 4
99 lines (83 loc) · 3.68 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
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Deploy PR previews
on:
pull_request_target:
types:
- opened
- reopened
- labeled
- synchronize
branches:
- main
paths:
- "content/**"
- "static/**"
- "styles/**"
- "syntaxes/**"
- "templates/**"
- "themes/**"
env:
DEPLOY_REPO_OWNER: OpenDreamProject
DEPLOY_REPO: od-dm-reference
concurrency:
group: "ci-security-${{ github.head_ref || github.run_id }}-${{ github.event_name }}"
cancel-in-progress: true
jobs:
security-checkpoint:
name: Check CI Clearance
if: github.event_name == 'pull_request_target' && (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id || github.event.pull_request.user.id == 55142896) && github.event.pull_request.state == 'open'
runs-on: ubuntu-latest
steps:
- name: "Remove Stale 'CI Cleared' Label"
if: github.event.action == 'synchronize' || github.event.action == 'reopened'
uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0
with:
labels: CI Cleared
- name: "Remove 'CI Approval Required' Label"
if: (github.event.action == 'synchronize' || github.event.action == 'reopened') || ((github.event.action == 'opened' || github.event.action == 'labeled') && contains(github.event.pull_request.labels.*.name, 'CI Cleared'))
uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0
with:
labels: CI Approval Required
- name: "Add 'CI Approval Required' Label"
if: (github.event.action == 'synchronize' || github.event.action == 'reopened') || ((github.event.action == 'opened' || github.event.action == 'labeled') && !contains(github.event.pull_request.labels.*.name, 'CI Cleared'))
uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf
with:
labels: CI Approval Required
- name: Fail if PR has Unlabeled new Commits from User
if: (github.event.action == 'synchronize' || github.event.action == 'reopened') || ((github.event.action == 'opened' || github.event.action == 'labeled') && !contains(github.event.pull_request.labels.*.name, 'CI Cleared'))
run: exit 1
deploy-preview:
needs: security-checkpoint
if: (!(cancelled() || failure()) && (needs.security-checkpoint.result == 'success' || (github.event_name != 'pull_request_target' && github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id && github.event.pull_request.user.id != 55142896)))
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.number }}/merge
- name: Setup Node
uses: actions/setup-node@v4
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Install Zora
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Install Stork
uses: baptiste0928/[email protected]
with:
crate: stork-search
version: "1.6.0"
- name: Build project
run: npm run build -- -u "https://ref.opendre.am/pr-preview/pr-${{ github.event.number }}"
- name: Build index
run: |
npm run build:search-config -- -u "https://ref.opendre.am/pr-preview/pr-${{ github.event.number }}"
npm run build:search-index
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./public/
umbrella-dir: ./pr-preview/
deploy-repository: ${{ env.DEPLOY_REPO_OWNER }}/${{ env.DEPLOY_REPO }}
custom-url: "ref.opendre.am"
action: deploy