-
Notifications
You must be signed in to change notification settings - Fork 2
49 lines (39 loc) · 1.39 KB
/
deploy-command.yml
File metadata and controls
49 lines (39 loc) · 1.39 KB
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
# Inputs:
# client_payload.pull_request.number - PR number
# client_payload.pull_request.head.sha - PR SHA
name: Create PR Staging Environment
on:
repository_dispatch:
types: [deploy-command]
env:
DOMAIN: ${{ format('{0}-{1}-pr{2}.surge.sh', github.event.repository.owner.login, github.event.repository.name, github.event.client_payload.pull_request.number) }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Dump context
env:
CONTEXT: ${{ toJson(github) }}
run: |
echo "Context: $CONTEXT"
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.pull_request.head.sha }}
- name: Install dependencies
run: npm ci
- name: Build static site
run: npx gatsby build
- name: Publish to surge.sh
run: npx surge ./public ${{ env.DOMAIN }}
env:
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
- name: Add comment to PR
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.client_payload.pull_request.number }}
body: |
${{ format('Published to [staging environment](https://{0})', env.DOMAIN) }}
To teardown, comment with the `/teardown` command.