From 7f078f573400469e32529d217b71ddec6af30160 Mon Sep 17 00:00:00 2001 From: tinqs-limited Date: Wed, 20 May 2026 07:26:00 +0100 Subject: [PATCH] =?UTF-8?q?ci:=20add=20release.yml=20=E2=80=94=20on-demand?= =?UTF-8?q?=20deploy=20via=20workflow=5Fdispatch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .gitea/workflows/release.yml | 71 ++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000000..6218efeacd --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,71 @@ +name: Release tinqs-git + +on: + workflow_dispatch: + inputs: + branch: + description: 'Branch to build and deploy' + required: true + default: 'tinqs/main' + restart: + description: 'Restart gitea service after deploy' + type: boolean + required: true + default: true + +jobs: + deploy: + runs-on: host + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.branch }} + + - uses: actions/setup-go@v5 + with: + go-version: '1.26.2' + + - uses: actions/setup-node@v4 + with: + node-version: '22' + + - run: npm install -g pnpm + + - name: Build tinqs-git + run: TAGS="bindata sqlite sqlite_unlock_notify" make build + + - name: Deploy to git.arikigame.com + env: + DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} + DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} + RESTART: ${{ github.event.inputs.restart }} + run: | + mkdir -p ~/.ssh + echo "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + + echo "Deploying tinqs-git to $DEPLOY_HOST..." + + scp -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no \ + gitea ubuntu@$DEPLOY_HOST:/tmp/tinqs-git + + ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no \ + ubuntu@$DEPLOY_HOST " + echo 'Backing up current binary...' + sudo cp /usr/local/bin/gitea /usr/local/bin/gitea.backup.\$(date +%Y%m%d-%H%M%S) || true + echo 'Stopping gitea...' + sudo systemctl stop gitea || true + echo 'Installing tinqs-git...' + sudo cp /tmp/tinqs-git /usr/local/bin/gitea + sudo chmod +x /usr/local/bin/gitea + sudo chown gitea:gitea /usr/local/bin/gitea || true + if [ '$RESTART' = 'true' ]; then + echo 'Starting gitea...' + sudo systemctl start gitea + sleep 2 + sudo systemctl status gitea --no-pager + else + echo 'Restart skipped (RESTART=false). Start manually: sudo systemctl start gitea' + fi + echo 'Deploy complete.' + "