70 lines
2.0 KiB
YAML
70 lines
2.0 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: Install Buildah
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y buildah
|
|
|
|
- name: Login to Gitea Registry
|
|
env:
|
|
REGISTRY_HOST: ${{ vars.REGISTRY_HOST }}
|
|
REGISTRY_PUSH_HOST: ${{ vars.REGISTRY_PUSH_HOST }}
|
|
REGISTRY_INSECURE: ${{ vars.REGISTRY_INSECURE }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
run: |
|
|
push_host="${REGISTRY_PUSH_HOST:-${REGISTRY_HOST}}"
|
|
tls_verify=true
|
|
if [ "${REGISTRY_INSECURE}" = "true" ]; then
|
|
tls_verify=false
|
|
fi
|
|
printf '%s' "${REGISTRY_PASSWORD}" | buildah login --tls-verify="${tls_verify}" -u "${GITHUB_REPOSITORY_OWNER}" --password-stdin "${push_host}"
|
|
|
|
- name: Build and Push Image
|
|
env:
|
|
REGISTRY_HOST: ${{ vars.REGISTRY_HOST }}
|
|
REGISTRY_PUSH_HOST: ${{ vars.REGISTRY_PUSH_HOST }}
|
|
REGISTRY_INSECURE: ${{ vars.REGISTRY_INSECURE }}
|
|
run: |
|
|
push_host="${REGISTRY_PUSH_HOST:-${REGISTRY_HOST}}"
|
|
tls_verify=true
|
|
if [ "${REGISTRY_INSECURE}" = "true" ]; then
|
|
tls_verify=false
|
|
fi
|
|
export BUILDAH_ISOLATION=chroot
|
|
image="${push_host}/${GITHUB_REPOSITORY}"
|
|
buildah bud --storage-driver=vfs --format docker -t "${image}:main" -t "${image}:sha-${GITHUB_SHA}" .
|
|
buildah push --tls-verify="${tls_verify}" "${image}:main"
|
|
buildah push --tls-verify="${tls_verify}" "${image}:sha-${GITHUB_SHA}"
|