Repository navigation
73 lines (60 loc) · 2.24 KB
/
Copy pathdeploy.yml
File metadata and controls
73 lines (60 loc) · 2.24 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
64
65
66
67
68
69
70
71
72
73
name: Deploy
# Replaces Travis CI. Builds the uberjar, copies it to both engine hosts
# (api-bible-docs web + worker generator) and restarts the supervisor program.
# Requires org secret ANYCHART_BOT_KEY: the anychart-bot private key, authorized
# as root on both hosts (servers-conf SSH_KEYS).
on:
push:
branches: [master, staging]
workflow_dispatch:
concurrency:
group: deploy-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: read
env:
HOSTS: "104.236.66.244 68.183.148.118"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Resolve target app
run: |
case "${GITHUB_REF_NAME}" in
master) echo "APP=reference-prod" >> "$GITHUB_ENV" ;;
staging) echo "APP=reference-stg" >> "$GITHUB_ENV" ;;
*) echo "No deploy target for ${GITHUB_REF_NAME}"; exit 1 ;;
esac
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "8"
- uses: DeLaGuardo/setup-clojure@13.2
with:
lein: 2.9.8
- uses: actions/cache@v4
with:
path: ~/.m2
key: m2-${{ hashFiles('project.clj') }}
restore-keys: m2-
- name: Build uberjar
run: |
lein sass4clj once
lein uberjar
- name: Install SSH key
env:
ANYCHART_BOT_KEY: ${{ secrets.ANYCHART_BOT_KEY }}
run: |
test -n "$ANYCHART_BOT_KEY" || { echo "ANYCHART_BOT_KEY secret is not set"; exit 1; }
install -d -m 700 ~/.ssh
printf '%s\n' "$ANYCHART_BOT_KEY" > ~/.ssh/id_deploy
chmod 600 ~/.ssh/id_deploy
cp .github/known_hosts ~/.ssh/known_hosts
- name: Copy jar and restart
run: |
SSH_OPTS="-i $HOME/.ssh/id_deploy -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes"
for host in $HOSTS; do
scp $SSH_OPTS "target/reference-3.0.0-standalone.jar" "root@${host}:/apps/${APP}/reference-3.0.0-standalone.jar.new"
ssh $SSH_OPTS "root@${host}" "mv /apps/${APP}/reference-3.0.0-standalone.jar.new /apps/${APP}/reference-3.0.0-standalone.jar && supervisorctl restart ${APP} && supervisorctl status ${APP}"
done