Files
blekin/.gitea/workflows/publish.yml
rob thijssen f62084eac7
Some checks are pending
Publish / backend (push) Waiting to run
CI / fmt (push) Successful in 33s
Publish / frontend (push) Successful in 45s
CI / clippy (push) Successful in 1m43s
CI / check (push) Successful in 1m44s
ci: gate publish jobs on commit message deploy directives
Publish jobs now only run when the commit message contains:
- "deploy: frontend" — deploys frontend only
- "deploy: backend" — deploys backend only
- "deploy: backend, frontend" or "deploy: frontend, backend" — both

Case-insensitive matching. Commits without a deploy directive
will only run CI (check/fmt/clippy), not publish.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-07 13:24:44 +03:00

88 lines
3.9 KiB
YAML

name: Publish
on:
push:
branches: [main]
env:
PUBLISH_KEY: |
${{ secrets.PUBLISH_KEY }}
jobs:
frontend:
runs-on: rust
if: >-
contains(github.event.head_commit.message, 'deploy: frontend')
|| contains(github.event.head_commit.message, 'deploy: backend, frontend')
|| contains(github.event.head_commit.message, 'deploy: frontend, backend')
|| contains(github.event.head_commit.message, 'Deploy: frontend')
|| contains(github.event.head_commit.message, 'Deploy: backend, frontend')
|| contains(github.event.head_commit.message, 'Deploy: frontend, backend')
|| contains(github.event.head_commit.message, 'Deploy: Frontend')
|| contains(github.event.head_commit.message, 'Deploy: Backend, Frontend')
|| contains(github.event.head_commit.message, 'Deploy: Frontend, Backend')
steps:
- uses: actions/checkout@v4
- name: Build frontend
run: |
cd crates/ericrfb-frontend
npm ci
npm run build
- name: SSH init
run: |
mkdir -p ~/.ssh
echo "${PUBLISH_KEY}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=accept-new gitea_ci@${{ vars.UI_HOST }} 'echo $(hostname -f) connection succeeded'
- name: Deploy static files to UI host
run: |
rsync --archive --compress --verbose --delete dist/ gitea_ci@${{ vars.UI_HOST }}:${{ vars.UI_PATH }}/
- name: Deploy nginx config and reload
run: |
rsync --archive --compress --verbose --rsync-path 'sudo rsync' asset/nginx/blekin.kosherinata.internal.conf gitea_ci@${{ vars.UI_HOST }}:/etc/nginx/sites-available/blekin.kosherinata.internal.conf
ssh gitea_ci@${{ vars.UI_HOST }} 'sudo /usr/bin/ln -sf /etc/nginx/sites-available/blekin.kosherinata.internal.conf /etc/nginx/sites-enabled/blekin.kosherinata.internal.conf && sudo /usr/bin/nginx -t && sudo /usr/bin/systemctl reload nginx.service'
backend:
runs-on: rust
if: >-
contains(github.event.head_commit.message, 'deploy: backend')
|| contains(github.event.head_commit.message, 'deploy: backend, frontend')
|| contains(github.event.head_commit.message, 'deploy: frontend, backend')
|| contains(github.event.head_commit.message, 'Deploy: backend')
|| contains(github.event.head_commit.message, 'Deploy: backend, frontend')
|| contains(github.event.head_commit.message, 'Deploy: frontend, backend')
|| contains(github.event.head_commit.message, 'Deploy: Backend')
|| contains(github.event.head_commit.message, 'Deploy: Backend, Frontend')
|| contains(github.event.head_commit.message, 'Deploy: Frontend, Backend')
steps:
- uses: actions/checkout@v4
- name: Build release binary
run: cargo build --release -p ericrfb-proxy
- name: SSH init
run: |
mkdir -p ~/.ssh
echo "${PUBLISH_KEY}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=accept-new gitea_ci@${{ vars.WS_HOST }} 'echo $(hostname -f) connection succeeded'
- name: Stop service
run: |
ssh gitea_ci@${{ vars.WS_HOST }} 'if systemctl is-active --quiet blekin.service; then sudo /usr/bin/systemctl stop blekin.service; fi'
- name: Deploy binary
run: |
rsync --archive --compress --verbose --rsync-path 'sudo rsync' target/release/ericrfb-proxy gitea_ci@${{ vars.WS_HOST }}:/usr/local/bin/ericrfb-proxy
- name: Deploy systemd unit
run: |
rsync --archive --compress --verbose --rsync-path 'sudo rsync' asset/systemd/blekin.service gitea_ci@${{ vars.WS_HOST }}:/etc/systemd/system/blekin.service
- name: Start and enable service
run: |
ssh gitea_ci@${{ vars.WS_HOST }} 'sudo /usr/bin/systemctl start blekin.service && ( systemctl is-enabled --quiet blekin.service || sudo /usr/bin/systemctl enable blekin.service )'