61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Test
|
|
run: go test ./...
|
|
|
|
- name: Build
|
|
run: go build .
|
|
|
|
publish:
|
|
if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main'
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Configure Registry Auth
|
|
env:
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
run: |
|
|
push_host="$(git remote get-url origin | sed -E 's#^[a-z]+://([^/]+)/.*#\1#')"
|
|
mkdir -p "${HOME}/.docker"
|
|
auth="$(printf '%s:%s' "${GITHUB_REPOSITORY_OWNER}" "${REGISTRY_PASSWORD}" | base64 -w0)"
|
|
printf '{"auths":{"%s":{"auth":"%s"}}}\n' "${push_host}" "${auth}" > "${HOME}/.docker/config.json"
|
|
chmod 600 "${HOME}/.docker/config.json"
|
|
|
|
- name: Install ko
|
|
run: GOBIN=/usr/local/bin go install github.com/google/ko@v0.18.0
|
|
|
|
- name: Build and Push Image
|
|
env:
|
|
KO_DEFAULTBASEIMAGE: gcr.io/distroless/static-debian12:nonroot
|
|
KO_DEFAULTPLATFORMS: linux/amd64,linux/arm64
|
|
run: |
|
|
push_host="$(git remote get-url origin | sed -E 's#^[a-z]+://([^/]+)/.*#\1#')"
|
|
export KO_DOCKER_REPO="${push_host}/${GITHUB_REPOSITORY}"
|
|
ko build --bare --insecure-registry --sbom=none --tags "main,sha-${GITHUB_SHA}" .
|