hsa-app/.forgejo/workflows/build.yml
Jean-Michel Tremblay f47e611e2c
All checks were successful
Build and Test / build-and-test (push) Successful in 36s
Deploy tagged releases via versioned dir + symlink swap
On tag push, scp the binary to ~/hsa-app/releases/hsa-app-V<tag>/hsa,
repoint the ~/hsa-app/hsa symlink, and restart the user systemd
service. Add deploy/hsa_app.service unit and deploy/INSTALL.md with
host layout, one-time install, deploy, and rollback steps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 15:08:20 -04:00

31 lines
1.3 KiB
YAML

name: Build and Test
on: [push]
jobs:
build-and-test:
runs-on: shell
steps:
- name: Checkout
run: |
git clone --branch ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
- name: Test
run: docker run --rm -w /src -v $PWD:/src golang:1.26 go test ./...
- name: Build
run: docker run --rm -w /src -v $PWD:/src -e CGO_ENABLED=0 golang:1.26 go build -buildvcs=false -ldflags "-s -w" -o hsa ./cmd/hsa
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: hsa
path: hsa
- name: Deploy
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ secrets.FORGEJO_SSH }}" > /tmp/deploy_key
chmod 600 /tmp/deploy_key
TAG=${{ github.ref_name }}
REL=hsa-app/releases/hsa-app-V$TAG
TARGET=${{ vars.HSA_APP_USER }}@${{ vars.HSA_APP_HOST }}
ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no $TARGET "mkdir -p $REL"
scp -i /tmp/deploy_key -o StrictHostKeyChecking=no hsa $TARGET:$REL/hsa
ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no $TARGET \
"cd hsa-app && chmod +x releases/hsa-app-V$TAG/hsa && ln -sfn releases/hsa-app-V$TAG/hsa hsa && systemctl --user restart hsa_app"
rm /tmp/deploy_key