Files
vasyansk 75134b6fac
Build / Build & push landing (push) Successful in 15s
Build / Deploy to prod (push) Successful in 5s
Build / Notify Max (push) Successful in 1s
add deploy
2026-06-15 13:47:50 +07:00

104 lines
4.2 KiB
YAML

name: Build
on:
push:
branches: [main, master]
paths:
- "landing/**"
- ".gitea/workflows/build.yaml"
env:
REGISTRY: git.realmanual.ru
IMAGE_PREFIX: ${{ gitea.repository }}
permissions:
contents: read
packages: write
jobs:
# Landing → static nginx image pushed to the Gitea registry.
# (The macOS .dmg is built locally via `make dmg` — Tauri can't cross-compile
# a macOS bundle on a Linux runner, and there is no self-hosted macOS runner.)
landing:
name: Build & push landing
runs-on: ubuntu-22.04
container: catthehacker/ubuntu:act-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
steps:
- uses: actions/checkout@v3
- name: Read version
id: version
run: echo "VERSION=$(cat ./landing/VERSION)" >> $GITHUB_OUTPUT
- name: Log in to Gitea Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./landing
file: ./landing/Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/spacesh-landing:${{ steps.version.outputs.VERSION }}
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/spacesh-landing:latest
# Push the compose stack to the prod host and roll the landing container.
# (DMG is uploaded separately from macOS via `make deploy-dmg`.)
deploy:
name: Deploy to prod
needs: landing
runs-on: ubuntu-22.04
container: catthehacker/ubuntu:act-latest
steps:
- uses: actions/checkout@v3
- name: Setup SSH
run: |
which ssh || (apt-get update && apt-get install -y openssh-client)
mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf '%s\n' "${{ secrets.SSH_KEY }}" > ~/.ssh/id_deploy
chmod 600 ~/.ssh/id_deploy
ssh-keyscan "${{ secrets.SSH_HOST }}" >> ~/.ssh/known_hosts 2>/dev/null || true
- name: Sync compose stack
run: |
ssh -i ~/.ssh/id_deploy "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}" \
"mkdir -p '${{ secrets.SSH_REMOTE_DIR }}/download'"
# Pin the exact image CI just pushed so the server pulls the right path/tag.
printf 'LANDING_IMAGE=%s/%s/spacesh-landing:%s\n' \
"${{ env.REGISTRY }}" "${{ env.IMAGE_PREFIX }}" "${{ needs.landing.outputs.version }}" > .env
scp -i ~/.ssh/id_deploy deploy/docker-compose.yaml deploy/proxy.conf .env \
"${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.SSH_REMOTE_DIR }}/"
- name: Pull & up
run: |
ssh -i ~/.ssh/id_deploy "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}" \
"cd '${{ secrets.SSH_REMOTE_DIR }}' && docker compose pull && docker compose up -d"
notify:
name: Notify Max
needs: [landing, deploy]
if: always()
runs-on: ubuntu-22.04
container: catthehacker/ubuntu:act-latest
steps:
- name: Compose & send summary
run: |
case "${{ needs.landing.result }}" in
success) line="✅ spacesh-landing собран (\`${{ needs.landing.outputs.version }}\`)";;
failure) line="❌ spacesh-landing — ошибка сборки";;
*) line="❔ spacesh-landing — ${{ needs.landing.result }}";;
esac
case "${{ needs.deploy.result }}" in
success) dline="🚀 задеплоен на прод";;
failure) dline="❌ деплой упал";;
*) dline="❔ деплой — ${{ needs.deploy.result }}";;
esac
line="$line"$'\n'"$dline"
url="${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_number }}"
text=$(printf '**Build landing**\n\n%s\n\n[лог](%s)' "$line" "$url")
curl -s -X POST "https://platform-api.max.ru/messages?chat_id=${{ secrets.MAX_CHAT_ID }}" \
-H "Authorization: ${{ secrets.MAX_BOT_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg t "$text" '{text:$t,format:"markdown"}')"