Merge pull request #6 from steinsiv/add-logo #18
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |