-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (68 loc) · 2.01 KB
/
main.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
name: Deploy to Github pages
on:
push:
branches: [master]
paths:
- .github/workflows/main.yml
- src/**/*
- public/**/*
- tools/**/*
- '*.{js,json}'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node:
- 12
env:
RELEASE_ROOT: .
REACT_APP_GA_ID: UA-36031394-1
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
env:
cache-name: artedecor-deps
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm install --prefer-offline
- name: Build website
env:
NODE_ENV: production
run: REACT_APP_COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA") REACT_APP_BUILD_TIME=$(date -Iminutes) npm run build
- name: Build sitemap
run: npm run build.sitemap
- name: Pre-render
run: npm run build.pages
- name: Deploy
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_ACTOR: deploy-bot
run: |
cat <<- EOF > $HOME/.netrc
machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
machine api.github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF
chmod 600 $HOME/.netrc
git config --global user.email "[email protected]"
git config --global user.name "$GITHUB_ACTOR"
git fetch origin gh-pages
git checkout -f gh-pages
ls $RELEASE_ROOT | grep -vE '^(build|CNAME|node_modules)$' | xargs rm -rf
mv build/* $RELEASE_ROOT
rmdir build
cp index.html 404.html
git add $RELEASE_ROOT
git commit -m "chore(release): deploy ${RELEASE_ROOT} ${PUBLIC_URL}"
git push origin gh-pages