Skip to content

Commit 960b741

Browse files
authored
chore: fix preview workflow vulnerability (#2069)
1 parent 5cdbda3 commit 960b741

File tree

3 files changed

+54
-19
lines changed

3 files changed

+54
-19
lines changed

.github/workflows/preview-build.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Surge PR Preview - Build Stage
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
build-preview:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: checkout PR
13+
uses: actions/checkout@v2
14+
with:
15+
ref: ${{ github.event.pull_request.head.sha }}
16+
17+
- name: build dist
18+
run: |
19+
npm install
20+
npm run site:build
21+
22+
- name: upload dist artifact
23+
uses: actions/upload-artifact@v2
24+
with:
25+
name: pr-build-dist
26+
path: public/

.github/workflows/preview-upload.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Surge PR Preview - Upload Stage
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Surge PR Preview - Build Stage"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
upload-preview:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
13+
14+
steps:
15+
- name: download dist artifact
16+
uses: dawidd6/action-download-artifact@v2
17+
with:
18+
workflow: ${{ github.event.workflow_run.workflow_id }}
19+
name: pr-build-dist
20+
path: public/
21+
22+
- name: deploy to Surge
23+
uses: afc163/surge-preview@v1
24+
with:
25+
surge_token: ${{ secrets.SURGE_TOKEN }}
26+
github_token: ${{ secrets.GITHUB_TOKEN }}
27+
build: echo done
28+
dist: public

.github/workflows/preview.yml

-19
This file was deleted.

0 commit comments

Comments
 (0)