-
Notifications
You must be signed in to change notification settings - Fork 4
50 lines (47 loc) · 1.87 KB
/
surge-preview-for-pr.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
name: Surge Preview for Pull Request
on:
pull_request:
# To manage 'surge-preview' action teardown, add default event types + closed event type
types: [opened, synchronize, reopened, closed]
branches:
- master
paths:
- '.github/workflows/surge-preview-for-pr.yml'
- 'public/surge/**/*'
permissions:
pull-requests: write # surge-preview creates or updates PR comments about the deployment status
jobs:
demo_preview: # the id is used by surge to generate the surge url
runs-on: ${{ vars.RUNNER_UBUNTU || 'ubuntu-20.04' }}
steps:
- uses: bonitasoft/actions/packages/surge-preview-tools@v3
id: surge-preview-tools
with:
surge-token: ${{ secrets.SURGE_TOKEN }}
- name: Echo surge preview tools output
run: |
echo "can-run-surge-command: ${{ steps.surge-preview-tools.outputs.can-run-surge-command }}"
echo "domain-exist: ${{ steps.surge-preview-tools.outputs.domain-exist }}"
echo "preview-url: ${{ steps.surge-preview-tools.outputs.preview-url }}"
echo "surge-token-valid: ${{ steps.surge-preview-tools.outputs.surge-token-valid }}"
- uses: actions/checkout@v4
- name: Build fake demo
if: ${{ github.event.action != 'closed' }}
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
mkdir site
cp -r public/surge/* site/
sed -i "s/@PR_NUMBER@/${PR_NUMBER}/g" site/index.html
- name: Publish Demo preview
if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true'
id: publish_demo_preview
uses: afc163/surge-preview@v1
with:
surge_token: ${{ secrets.SURGE_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
dist: site
failOnError: true
teardown: true
build: |
ls -lh site