-
Notifications
You must be signed in to change notification settings - Fork 39
63 lines (57 loc) · 2.03 KB
/
deploy.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
name: Manual Deploy
on:
#push:
# branches:
# - deploy
workflow_dispatch:
inputs:
hostname:
description: 'Server hostname Eg. "planet.dev.ole.org"'
required: true
default: 'planet.dev.ole.org'
buildname:
description: 'Planet Image name Eg. "0.13.4-deploy-d6b59441"'
required: false
env:
DOCKER_ORG: treehouses
DOCKER_REPO_TAG: planet-tags
DOCKER_REPO: planet
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: sshagent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSHKEY }}
- name: deploy
run: |
if [[ "${{ github.event.inputs.hostname }}" == "" ]]; then
SERVER_HOST="planet.dev.ole.org"
else
SERVER_HOST="${{ github.event.inputs.hostname }}"
fi
PLANET_VERSION=$(jq '.version' package.json | sed -e 's/^"//' -e 's/"$//')
if [[ "${{ github.event.inputs.buildname }}" == "" ]]; then
BUILD="$PLANET_VERSION-$GITHUB_REF_NAME-${GITHUB_SHA::8}"
# BUILD="0.13.4-deploy-d6b59441"
else
SERVER_HOST="${{ github.event.inputs.hostname }}"
fi
PLANET_REPO="$DOCKER_ORG/$DOCKER_REPO_TAG:$BUILD"
DBINIT_REPO="$DOCKER_ORG/$DOCKER_REPO_TAG:db-init-$BUILD"
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "planet.dev.ole.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFqXBJPFe+pH3L57o1ildAxHssG4lpkloTcw3Wbs64c7bL8M6hR0rre4ufpCKboVLn4trJqbKOPWtFgBJHsgqXA=" > ~/.ssh/known_hosts
# echo "planet.earth.ole.org ...."
ssh root@$SERVER_HOST <<EOF
docker pull $PLANET_REPO
docker pull $DBINIT_REPO
docker tag $PLANET_REPO "$DOCKER_ORG/$DOCKER_REPO:local"
docker tag $DBINIT_REPO "$DOCKER_ORG/$DOCKER_REPO:db-init-local"
docker images
treehouses services planet restart
EOF