63 lines
1.7 KiB
YAML
63 lines
1.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, dev]
|
|
tags: ['v*']
|
|
pull_request:
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: [debian-latest]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.27"
|
|
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
- name: Test
|
|
run: go test -v ./...
|
|
|
|
docker:
|
|
# build & push image only on tags (releases) and dev branch (dev deploy)
|
|
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/dev'
|
|
needs: test
|
|
runs-on: [debian-latest]
|
|
env:
|
|
# dind sidecar listens on tcp; job containers reach it via the docker bridge gateway
|
|
DOCKER_HOST: tcp://172.17.0.1:2375
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Docker CLI
|
|
run: |
|
|
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-27.3.1.tgz -o /tmp/docker.tgz && tar -xzf /tmp/docker.tgz -C /tmp && mv /tmp/docker/docker /usr/local/bin/docker && chmod +x /usr/local/bin/docker
|
|
|
|
- name: Set up Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.archfox.org
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
git.archfox.org/poslop/palette:${{ gitea.ref_name }}
|
|
${{ startsWith(gitea.ref, 'refs/tags/') && 'git.archfox.org/poslop/palette:latest' || '' }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|