forked from dugnadctf/fiskebot
-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (38 loc) · 1.59 KB
/
cicd.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
name: DigitalOcean CICD
on:
push:
branches:
- master
workflow_dispatch:
permissions: {}
env:
USER: cee
APP_PATH: /home/cee/app/fiskebot/
HOST: ${{ secrets.DEPLOY_IP }}
SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure SSH on github runner
run: |
mkdir "/home/runner/.ssh/"
echo "$SSH_KEY" > "/home/runner/.ssh/private.pem"
chmod 600 "/home/runner/.ssh/private.pem"
printf "Host docean\n HostName $HOST\n User $USER\n IdentityFile /home/runner/.ssh/private.pem\n StrictHostKeyChecking no\n" > "/home/runner/.ssh/config"
- name: Build docker image
run: |
docker build -t steinsiv/fiskebot:latest .
docker save steinsiv/fiskebot:latest | gzip > steinsiv_fiskebot_latest.tar.gz
cat /home/runner/.ssh/config
cat /home/runner/.ssh/private.pem
- name: Deploy docker compose and .env file
run: |
scp docker-compose.yml "docean:$APP_PATH/docker-compose.yml"
scp steinsiv_fiskebot_latest.tar.gz "docean:$APP_PATH/steinsiv_fiskebot_latest.tar.gz"
ssh docean "cd $APP_PATH && docker load < steinsiv_fiskebot_latest.tar.gz && rm steinsiv_fiskebot_latest.tar.gz && docker compose up -d"
- name: Cleanup SSH configs just in case
if: always()
run: |
rm -rf "/home/runner/.ssh"