Skip to content

Commit

Permalink
update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ropc committed Feb 13, 2024
1 parent 5390c89 commit fed0377
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 36 deletions.
9 changes: 0 additions & 9 deletions .github/scripts/decrypt_secret.sh

This file was deleted.

Binary file removed .github/scripts/githubaction-key.pem.gpg
Binary file not shown.
38 changes: 12 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,17 @@ jobs:
tags: ropc/meme-bot:latest
deploy:
needs: docker-build-push
# The type of runner that the job will run on
if: ${{ github.actor == 'ropc' }}
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4.1.1

# this decrypts the ssh key and stores it in $HOME/secrets/githubaction-key.pem
# maybe we should add a step to delete after deploying?
- name: Decrypt ssh key
env:
SSH_KEY_PASSPHRASE: ${{ secrets.SSH_KEY_PASSPHRASE }}
REMOTE_DIR: ${{ secrets.REMOTE_DIR }}
run: $GITHUB_WORKSPACE/.github/scripts/decrypt_secret.sh

- name: Pull from host and deploy
env:
SSH_DESTINATION: ${{ secrets.SSH_DESTINATION }}
REMOTE_DIR: ${{ secrets.REMOTE_DIR }}
run: ssh -oStrictHostKeyChecking=no -T -i $HOME/secrets/githubaction-key.pem $SSH_DESTINATION "cd $REMOTE_DIR && git pull -f && sudo docker-compose -f docker-compose.yml -f docker-compose.prod.yml pull && sudo docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d"

- name: cleanup
env:
SSH_DESTINATION: ${{ secrets.SSH_DESTINATION }}
REMOTE_DIR: ${{ secrets.REMOTE_DIR }}
continue-on-error: true
run: ssh -oStrictHostKeyChecking=no -T -i $HOME/secrets/githubaction-key.pem $SSH_DESTINATION "sudo docker system prune -f"
- name: pull image and run updated container on remote host
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /home/ropc/code/meme-bot \
&& git pull --rebase \
&& docker compose -f docker-compose.yml -f docker-compose.prod.yml up --detach --pull missing \
&& docker system prune -f
2 changes: 1 addition & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
check_suite:
types:
- completed
status: {}
status:

jobs:
docker-build:
Expand Down

0 comments on commit fed0377

Please sign in to comment.