-
Notifications
You must be signed in to change notification settings - Fork 251
90 lines (79 loc) · 2.89 KB
/
deploy-draft.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
name: Deploy branch draft on Netlify
on:
pull_request:
types: [labeled, opened, synchronize]
jobs:
build-deploy:
if: |
(github.event.action == 'labeled' && github.event.label.name == 'deploy') ||
(github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'deploy'))
runs-on: ubuntu-latest
steps:
- name: inject slug/short variables
uses: rlespinasse/[email protected]
- name: compose a name for the build environment
run: echo "BUILD_ENV_NAME=pr-${{ github.event.number }}-${{ env.GITHUB_HEAD_REF_SLUG }}" >> $GITHUB_ENV
- name: create a github deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.BUILD_ENV_NAME }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 # fetch whole repo so git-restore-mtime can work
- name: Adjust file watchers limit
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Yarn install
run: npx yarn install --immutable
env:
NODE_ENV: ${{ secrets.NODE_ENV }}
- name: Checking Gatsby cache
id: gatsby-cache-build
uses: actions/cache@v2
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-develop-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-gatsby-build-develop-
- name: Fix mtimes
run: yarn fix-mtimes --force
- name: Gatsby build
run: yarn build
env:
APP_ENV: staging
NODE_ENV: ${{ secrets.NODE_ENV }}
NODE_OPTIONS: --max-old-space-size=4096
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_INDEX_NAME: edb-docs-staging
INDEX_ON_BUILD: false
- name: Deploy to Netlify
id: netlify-deploy
uses: nwtgck/[email protected]
with:
publish-dir: './public'
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions"
alias: ${{ github.head_ref }}
github-deployment-environment: ${{ env.BUILD_ENV_NAME }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DEVELOP_SITE_ID }}
- name: update the github deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.netlify-deploy.outputs.deploy-url }}