Files
poster-studio-server/.gitea/workflows/deploy.yml
T
codex-bot 8f6d5501f9
Verify and deploy poster studio service / verify-deploy (push) Has been cancelled
feat: initialize poster studio web service
2026-09-19 01:15:31 +08:00

44 lines
2.0 KiB
YAML

name: Verify and deploy poster studio service
on:
push: { branches: [main] }
pull_request:
workflow_dispatch:
concurrency: { group: poster-studio-production, cancel-in-progress: true }
jobs:
verify-deploy:
runs-on: ubuntu-latest
container: { image: "docker:27-cli" }
timeout-minutes: 30
env:
SOURCE_SERVER: ${{ gitea.server_url }}
SOURCE_REPOSITORY: ${{ gitea.repository }}
SOURCE_REVISION: ${{ gitea.sha }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
ADMIN_TOKEN: ${{ secrets.ADMIN_TOKEN }}
steps:
- name: Fetch exact revision
env: { SOURCE_TOKEN: "${{ secrets.GITEA_TOKEN || gitea.token }}" }
run: |
set -eu
apk add --no-cache python3
python3 - <<'PY'
import io,os,shutil,tarfile,tempfile,urllib.request
from pathlib import Path
url=f"{os.environ['SOURCE_SERVER'].rstrip('/')}/api/v1/repos/{os.environ['SOURCE_REPOSITORY']}/archive/{os.environ['SOURCE_REVISION']}.tar.gz"
request=urllib.request.Request(url,headers={'Authorization':'token '+os.environ['SOURCE_TOKEN']})
with urllib.request.urlopen(request,timeout=60) as response:data=response.read()
with tempfile.TemporaryDirectory() as directory:
with tarfile.open(fileobj=io.BytesIO(data),mode='r:gz') as archive:archive.extractall(directory,filter='data')
shutil.copytree(next(Path(directory).iterdir()),Path.cwd(),dirs_exist_ok=True)
PY
- run: docker build --target test -t "poster-studio-server:$SOURCE_REVISION-test" .
- if: gitea.ref == 'refs/heads/main' && gitea.event_name != 'pull_request'
run: docker build --target runtime -t "poster-studio-server:$SOURCE_REVISION" .
- if: gitea.ref == 'refs/heads/main' && gitea.event_name != 'pull_request'
run: |
set -eu
test -n "$POSTGRES_PASSWORD"
test -n "$ADMIN_TOKEN"
export DEPLOY_IMAGE="poster-studio-server:$SOURCE_REVISION"
sh scripts/deploy.sh