52 lines
1.3 KiB
YAML
52 lines
1.3 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 Docker and Skopeo
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y docker.io skopeo
|
|
|
|
- name: Build and Push Image
|
|
env:
|
|
REGISTRY_HOST: ${{ vars.REGISTRY_HOST }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
run: |
|
|
local_image="${GITHUB_REPOSITORY##*/}:ci"
|
|
archive="/tmp/${GITHUB_REPOSITORY##*/}.tar"
|
|
docker build -t "${local_image}" .
|
|
docker save "${local_image}" -o "${archive}"
|
|
for tag in main "sha-${GITHUB_SHA}"; do
|
|
skopeo copy --dest-creds "${GITHUB_REPOSITORY_OWNER}:${REGISTRY_PASSWORD}" --dest-tls-verify=false "docker-archive:${archive}" "docker://${REGISTRY_HOST}/${GITHUB_REPOSITORY}:${tag}"
|
|
done
|