CI/CD / BackEnd (push) Successful in 1m27s
CI/CD / WebPlayer (push) Successful in 39s
CI/CD / Deploy (push) Skipped
CI/CD / BackEnd (pull_request) Successful in 1m16s
CI/CD / WebPlayer (pull_request) Successful in 39s
CI/CD / Deploy (pull_request) Skipped
Remove deploy/nginx and the nginx service from compose.prod.yml: the shared edge in Infrastructure owns ports 80/443 and serves every domain. Make the deploy job fail when zitadel-init or seaweedfs-init fail, and document the runner and edge setup.
116 lines
3.3 KiB
YAML
116 lines
3.3 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: ['**']
|
|
pull_request:
|
|
branches: ['**']
|
|
|
|
concurrency:
|
|
group: production-deploy
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
backend-tests:
|
|
name: BackEnd
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '10.0.x'
|
|
|
|
- name: Restore
|
|
run: dotnet restore Musify.slnx
|
|
|
|
- name: Build
|
|
run: dotnet build Musify.slnx --no-restore -c Release
|
|
|
|
- name: Test
|
|
run: dotnet test Musify.slnx --no-build -c Release
|
|
|
|
web-player-checks:
|
|
name: WebPlayer
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
defaults:
|
|
run:
|
|
working-directory: web-player
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: npm
|
|
cache-dependency-path: web-player/package-lock.json
|
|
|
|
- run: npm ci
|
|
|
|
- name: Type-check
|
|
run: npm run check
|
|
|
|
- name: Lint
|
|
run: npm run lint
|
|
|
|
# Runs on the production host itself, through the existing self-hosted
|
|
# Gitea Actions runner (act_runner), which also carries a "production"
|
|
# label registered in native (non-docker) mode so its steps see the host's
|
|
# real Docker daemon directly (Docker socket + a bind-mounted deploy
|
|
# directory — see deploy/README.md for how that runner is set up).
|
|
#
|
|
# DEPLOY_PATH is the persistent clone already on that host (the one whose
|
|
# deploy/.env.prod is filled in and matches SharedServices/.env.prod) —
|
|
# deploy reuses it instead of a fresh checkout, since .env.prod is
|
|
# untracked and only lives there.
|
|
deploy:
|
|
name: Deploy
|
|
needs: [backend-tests, web-player-checks]
|
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
runs-on: [production]
|
|
timeout-minutes: 20
|
|
env:
|
|
DEPLOY_PATH: /home/ubuntu/deploys/musify
|
|
COMPOSE: docker compose --env-file deploy/.env.prod -f deploy/compose.yml -f deploy/compose.prod.yml
|
|
steps:
|
|
- name: Pull latest master
|
|
run: |
|
|
set -euo pipefail
|
|
git config --global --add safe.directory "$DEPLOY_PATH"
|
|
cd "$DEPLOY_PATH"
|
|
git fetch origin master
|
|
git reset --hard origin/master
|
|
|
|
- name: Migrate database, generate keys
|
|
run: |
|
|
set -euo pipefail
|
|
cd "$DEPLOY_PATH"
|
|
$COMPOSE up -d wait-for-postgres keys-init migrate
|
|
|
|
# Both jobs verify themselves through the public auth./s3. URLs, served
|
|
# by the shared edge nginx (Infrastructure's edge/), and are idempotent.
|
|
- name: Create OIDC app and S3 bucket
|
|
run: |
|
|
set -euo pipefail
|
|
cd "$DEPLOY_PATH"
|
|
$COMPOSE up -d seaweedfs-init zitadel-init
|
|
for job in musify-seaweedfs-init musify-zitadel-init; do
|
|
code=$(docker wait "$job")
|
|
if [ "$code" != "0" ]; then
|
|
docker logs "$job"
|
|
echo "$job exited with $code"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
- name: Build and start apps
|
|
run: |
|
|
set -euo pipefail
|
|
cd "$DEPLOY_PATH"
|
|
$COMPOSE --profile apps up -d --build api worker gateway web-player
|