This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
name: Deploy backend
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- backend/**
|
||||
- .gitea/workflows/deploy-backend.yaml
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: tencent-prod
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build and deploy on the Docker host
|
||||
shell: bash
|
||||
env:
|
||||
DATABASE_URL: ${{ secrets.DATABASE_URL }}
|
||||
WECHAT_APP_ID: ${{ secrets.WECHAT_APP_ID }}
|
||||
WECHAT_APP_SECRET: ${{ secrets.WECHAT_APP_SECRET }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd backend
|
||||
exec 9>/tmp/ballet-island-deploy.lock
|
||||
flock -w 600 9
|
||||
|
||||
latest_main="$(git ls-remote origin refs/heads/main | cut -f1)"
|
||||
test -n "$latest_main"
|
||||
if [ "$(git rev-parse HEAD)" != "$latest_main" ]; then
|
||||
echo "Skipping deployment: a newer main commit exists."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export IMAGE_TAG="$(git rev-parse --short=12 HEAD)"
|
||||
compose=(docker compose --env-file /dev/null -f compose.prod.yaml)
|
||||
"${compose[@]}" config --quiet
|
||||
"${compose[@]}" build api
|
||||
"${compose[@]}" up -d --wait --wait-timeout 180
|
||||
curl --fail --silent --show-error http://127.0.0.1:8080/readyz
|
||||
|
||||
- name: Show container status
|
||||
if: always()
|
||||
shell: bash
|
||||
run: |
|
||||
docker ps --all \
|
||||
--filter label=com.docker.compose.project=ballet-island \
|
||||
--format 'table {{.Names}}\t{{.Image}}\t{{.Status}}'
|
||||
Reference in New Issue
Block a user