-
Notifications
You must be signed in to change notification settings - Fork 17
63 lines (52 loc) · 1.86 KB
/
deploy.yml
File metadata and controls
63 lines (52 loc) · 1.86 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Deploy
on:
push:
branches: [ "master" ]
workflow_dispatch: # For action testing you can also run this manually
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Build
run: |
npm install
npm run build
date > build/builddate.txt
git rev-parse --short HEAD > build/commit.txt
- name: Deploy to Production
if: github.ref == 'refs/heads/master'
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"
run: |
mkdir -p ~/bin
export PATH="${HOME}/bin:${PATH}"
wget -O ~/bin/git-filter-repo https://raw.githubusercontent.com/newren/git-filter-repo/7b3e714b94a6e5b9f478cb981c7f560ef3f36506/git-filter-repo
chmod +x ~/bin/git-filter-repo
ls -la
eval "$(ssh-agent -s)"
ssh-add - <<< "${DEPLOY_KEY}"
git clone git@github.com:scribear/v.git
git config --global user.email "angrave@illinois.edu"
git config --global user.name "scribear-bot"
cd v
ls -la
export SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`
# git-filter-repo expects a fresh clone
# git-filter-repo --path latest --invert-paths
# TODO Need to debug why the above fails;
# we can get error later when git push origin master
# "fatal: 'origin' does not appear to be a git repository"
# The following should not be required if git-filter-repo works
git rm -rf latest
git commit -m "Removing previous latest dir"
mkdir -p latest
mv ../build/* latest
git add latest
git commit -m "Commit Deploy: ${SHORT_SHA}"
git push origin master