Skip to content

build -> image [DEPLOY] #32

build -> image [DEPLOY]

build -> image [DEPLOY] #32

name: Deploy Docker Compose
on: push
env:
DEPLOY_SRC: "docker-compose.yaml"
jobs:
deploy:
if: contains(github.event.head_commit.message, '[DEPLOY]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clear
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script_stop: true
script: |
cd ${{ secrets.TARGET_DOCKER_COMPOSE }}
docker compose down --remove-orphans
- name: Deploy file
uses: easingthemes/ssh-deploy@main
with:
REMOTE_HOST: ${{ secrets.HOST }}
REMOTE_USER: ${{ secrets.USERNAME }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
ARGS: "-rlzav --delete"
SOURCE: ${{ env.DEPLOY_SRC }}
TARGET: ${{ secrets.TARGET_DOCKER_COMPOSE }}
- name: Restart docker compose
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script_stop: true
script: |
cd ${{ secrets.TARGET_DOCKER_COMPOSE }}
docker compose pull
docker compose up -d
docker system prune -af --volumes