66 lines
2.1 KiB
YAML
66 lines
2.1 KiB
YAML
name: Docker Compose Remove Stack
|
|
|
|
on:
|
|
workflow_call:
|
|
secrets:
|
|
DEPLOY_HOST:
|
|
required: true
|
|
type: string
|
|
DEPLOY_USERNAME:
|
|
required: true
|
|
type: string
|
|
DEPLOY_SSHKEY:
|
|
required: true
|
|
type: string
|
|
DEPLOY_PORT:
|
|
required: true
|
|
type: string
|
|
PUSHOVER_USER_TOKEN:
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: "[ON RUNNER] Notify Build Start"
|
|
uses: https://git.tainton.uk/actions/pushover-action@v1.1.0
|
|
env:
|
|
PUSHOVER_APP_TOKEN: ${{ secrets.PUSHOVER_APP_TOKEN }}
|
|
PUSHOVER_USER_TOKEN: ${{ secrets.PUSHOVER_USER_TOKEN }}
|
|
with:
|
|
message: "Removing stack ${{ gitea.repository }}"
|
|
title: 'Stack Removal Started'
|
|
url: "${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}"
|
|
url_title: 'View Logs'
|
|
|
|
- name: "[ON RUNNER] Set project variables"
|
|
run: |
|
|
projectname="${{ gitea.event.repository.name }}"
|
|
echo "project_name=$projectname" >> $GITEA_ENV
|
|
echo "project_folder=/home/${{ secrets.DEPLOY_USERNAME }}/$projectname" >> $GITEA_ENV
|
|
|
|
- name: "[ON HOST] Remove Stack"
|
|
uses: appleboy/ssh-action@v1.2.2
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
username: ${{ secrets.DEPLOY_USERNAME }}
|
|
key: ${{ secrets.DEPLOY_SSHKEY }}
|
|
port: ${{ secrets.DEPLOY_PORT }}
|
|
script: |
|
|
cd ${{ env.project_folder }}
|
|
docker compose --env-file .env down
|
|
cd ..
|
|
rm -rf ${{ env.project_folder }}
|
|
|
|
- name: "[ON RUNNER] Notify Build End"
|
|
uses: https://git.tainton.uk/actions/pushover-action@v1.1.0
|
|
env:
|
|
PUSHOVER_APP_TOKEN: ${{ secrets.PUSHOVER_APP_TOKEN }}
|
|
PUSHOVER_USER_TOKEN: ${{ secrets.PUSHOVER_USER_TOKEN }}
|
|
with:
|
|
message: "Removed stack ${{ gitea.repository }}"
|
|
title: 'Stack Removal ${{ job.status }}'
|
|
url: "${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}"
|
|
url_title: 'View Logs'
|