fix(exams): Fix link for exam server #95
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: Deployment | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
check_deployment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check PR has no-deployment label | |
id: check_deployment | |
uses: shioyang/check-pr-labels-on-push-action@v1.0.12 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
labels: '["no-deployment"]' | |
timeout-minutes: 5 | |
outputs: | |
deploy: "${{ ! fromJson(steps.check_deployment.outputs.result) }}" | |
pre_commit_ci: | |
uses: vutfitdiscord/rubbergod/.github/workflows/lint.yml@main | |
deployment_production: | |
runs-on: ubuntu-latest | |
environment: Production | |
needs: [pre_commit_ci, check_deployment] | |
if: github.ref == 'refs/heads/main' && needs.check_deployment.outputs.deploy == 'true' | |
steps: | |
- name: Execute deployment on SSH | |
uses: appleboy/ssh-action@v1.2.0 | |
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 |