hsa-app/.forgejo/workflows/build.yml
Jean-Michel Tremblay 2f817d16d0
All checks were successful
Build and Test / build-and-test (push) Successful in 35s
CI: deploy binary to versioned dir on tag push
On a tag push, scp the built hsa binary to ~/hsa-app-V<tag> on the
target host (created if missing). Reuses the FORGEJO_SSH key; host and
user come from the HSA_APP_HOST / HSA_APP_USER repo vars. Branch
pushes still only build and test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 14:44:16 -04:00

27 lines
1.1 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
DEST=hsa-app-V${{ github.ref_name }}
ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no ${{ vars.HSA_APP_USER }}@${{ vars.HSA_APP_HOST }} "mkdir -p $DEST"
scp -i /tmp/deploy_key -o StrictHostKeyChecking=no hsa ${{ vars.HSA_APP_USER }}@${{ vars.HSA_APP_HOST }}:$DEST/hsa
rm /tmp/deploy_key