Skip to content

changes to template #80

changes to template

changes to template #80

Workflow file for this run

name: Deployment
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
pre_commit_ci:
uses: vutfitdiscord/rubbergod/.github/workflows/lint.yml@main
deployment_production:
runs-on: ubuntu-latest
environment: Production
needs: pre_commit_ci
if: github.ref == 'refs/heads/main' && !contains(github.event.pull_request.labels.*.name, 'no-deployment')
steps:
- name: Execute deployment on SSH
uses: appleboy/[email protected]
with:
host: ${{ secrets.PRODUCTION_HOST }}
key: ${{ secrets.PRODUCTION_SSH_KEY }}
username: ${{ secrets.PRODUCTION_USERNAME }}
port: 22
script: |
echo "================== Lock Mutex =================="
LOCK="/tmp/deployment.lock"
remove_lock()
{
rm -f "$LOCK"
}
acquire_failed()
{
echo "Failed to acquire lock, perphaps a stale deployment is running requiring manual fix?"
exit 1
}
# !IMPORTANT: For this to work, the remote server has to have `procmail` installed.
# Try to lock 5 times with a 60s sleep time between retries
# Remove any lock older than 10min (600s) and then wait 30s
lockfile -60 -r 5 -l 600 -s 30 "$LOCK" || acquire_failed
# Remove lock on exit
trap remove_lock EXIT
echo "================== Pull Changes =================="
cd rubbergod
git pull
echo "================== Build Image =================="
docker build . --tag rubbergod-bot
echo "================== Restart Services =================="
docker compose down && docker compose up -d
echo "================== Clean Up Images =================="
echo "y" | docker image prune -a