-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (56 loc) · 2.25 KB
/
deploy-production.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
name: Production CI
on:
push:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
buildAndDeploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- run: git submodule update --init --recursive
- name: Save original git author and git email
run: |
echo "git_email=$(git log --format='%ae' HEAD^!)" >> $GITHUB_ENV
echo "git_name=$(git log --format='%an' HEAD^!)" >> $GITHUB_ENV
- uses: actions/[email protected]
- name: Change homepage in package.json
run: sed -i 's/place-holder/OATutor/g' package.json
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
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: Run CI install
run: npm ci
- name: Run build
run: npm run build
env:
REACT_APP_OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
CI: false
- uses: actions/checkout@v2
with:
ref: "gh-pages"
path: "gh-build"
- name: Push
run: |
cd gh-build
git rm -rf .
git clean -fxd
rsync -av ../build/ .
git add .
git config --local user.email "${{ env.git_email }}"
git config --local user.name "${{ env.git_name }}"
git diff --cached --quiet --exit-code && echo "no changes to platform, exiting early" && exit 0
git commit -m "deploy commit: CAHLR/OATutor@$GITHUB_SHA"
git push