.github/workflows/ci.yml
raw ยท 2000 bytes
name: flatgit CI
on:
workflow_dispatch:
push:
branches: ["master"]
tags: ["v*"]
pull_request:
branches: ["master"]
permissions:
contents: read
jobs:
build:
name: Go build and test
runs-on: ubuntu-latest
steps:
- &checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.26.x"
cache: true
- name: Test
run: go test ./...
- name: Vet
run: go vet ./...
- name: Build
run: go build -trimpath -o ./bin/flatgit ./cmd/flatgit
- name: Smoke test
run: ./bin/flatgit version
docker:
name: Docker image
runs-on: ubuntu-latest
needs:
- build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: read
packages: write
steps:
- *checkout
- name: Set image name
shell: bash
run: |
set -eu
image="ghcr.io/${GITHUB_REPOSITORY}"
image="${image,,}"
echo "IMAGE_NAME=${image}" >> "$GITHUB_ENV"
echo "Image name: ${image}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ github.ref_name }}-debian-slim
type=raw,value=latest-debian-slim
- name: Build and push image
uses: docker/build-push-action@v7
with:
context: .
file: ./dockerfiles/github.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}