-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (89 loc) · 3.07 KB
/
ci.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
100
101
102
103
104
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# Caching: root project
- name: Get Yarn cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Use Yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-${{ matrix.node-version }}-
yarn-${{ runner.os }}-
- name: Use node_modules cache
id: node-modules-cache
uses: actions/cache@v2
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('./yarn.lock') }}
restore-keys: |
node-modules-${{ runner.os }}-${{ matrix.node-version }}-
node-modules-${{ runner.os }}-
- name: Project installation
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn install --prefer-offline --frozen-lockfile --non-interactive
env:
CI: true
- name: Checks
run: yarn run check
- name: Set deployment url
run: node ./scripts/deploy/surge-domains.js url DEPLOYMENT_URL >> $GITHUB_ENV
env:
PROD: ${{ github.ref == 'refs/heads/main' }}
- name: Set deployment environment
run: node ./scripts/deploy/surge-domains.js env DEPLOYMENT_ENV >> $GITHUB_ENV
env:
PROD: ${{ github.ref == 'refs/heads/main' }}
- name: Create GitHub deployment
if: env.DEPLOYMENT_URL
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.DEPLOYMENT_ENV }}
ref: ${{ github.head_ref || github.ref }}
- name: Deployment (Staging)
if: github.ref != 'refs/heads/main'
run: yarn deploy
env:
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
- name: Deployment (Production)
if: github.ref == 'refs/heads/main'
run: yarn deploy
env:
PROD: true
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
- name: Update GitHub deployment status
if: always() && env.DEPLOYMENT_URL
uses: bobheadxi/[email protected]
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: "https://${{ env.DEPLOYMENT_URL }}"