From b323ed5656639b28e8b14cd915d361d745c62853 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Sat, 20 Jun 2026 10:33:38 -0500 Subject: [PATCH] repo: files for deployment --- .github/workflows/build.yaml | 29 +++++++++++++++++++++++++++++ .github/workflows/ci.yaml | 2 +- .github/workflows/scripts/deploy.sh | 29 +++++++++++++++++++++++++++++ Justfile | 10 ++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yaml create mode 100755 .github/workflows/scripts/deploy.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..e3a4224 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,29 @@ +name: Build Release Artifact +on: + workflow_dispatch: +jobs: + compile: + timeout-minutes: 10 + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 + - uses: actions/setup-go@v6 + with: + cache: true + go-version-file: go.mod + - name: Show System + run: | + uname -a + just sysinfo + - name: Build Artifact + run: | + just compile + - uses: actions/upload-artifact@v7 + with: + name: "ubs" + path: ".bin/nerfs" + retention-days: 4 + compression-level: 9 + if-no-files-found: error + overwrite: true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6d66fbb..9e5f2de 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ on: jobs: run-tests: timeout-minutes: 5 - runs-on: fedora-41 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 - uses: extractions/setup-just@v2 diff --git a/.github/workflows/scripts/deploy.sh b/.github/workflows/scripts/deploy.sh new file mode 100755 index 0000000..67cf3a5 --- /dev/null +++ b/.github/workflows/scripts/deploy.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -euo pipefail + +binary="${1}" + +archives=$(curl -s -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/cattlecloud/${binary}/actions/artifacts") + +best=$(echo "${archives}" | jq -r '.artifacts | sort_by(.created_at) | last | .archive_download_url') +dest="/tmp/${binary}.zip" +file="/tmp/${binary}" + +echo "downloading ${best} into ${dest}" +curl -L -H "Authorization: Bearer ${GITHUB_TOKEN}" -H "X-GitHub-Api-Version: 2022-11-28" -o "${dest}" -s "${best}" +pushd /tmp && unzip "${dest}" && popd +echo "download complete." + +scp "${file}" "${HOST}:~/${binary}" +ssh -t "${HOST}" "sudo mv ~/${binary} /opt/bin/${binary}" +ssh -t "${HOST}" "sudo systemctl restart ${binary}" +ssh -t "${HOST}" "sudo systemctl status ${binary}" + +rm "${dest}" "${file}" +echo "done." + diff --git a/Justfile b/Justfile index 977ea88..78e3b5d 100644 --- a/Justfile +++ b/Justfile @@ -53,3 +53,13 @@ lint: vet [group('build')] init: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4 + +# deploy artifact +[group('deploy')] +deploy host: + HOST={{host}} envy exec gh-cattle $scripts/deploy.sh nerfs + +# create release artifact +[group('deploy')] +artifact: + gh workflow run build.yaml