57 lines
1.6 KiB
YAML
57 lines
1.6 KiB
YAML
name: Build and publish
|
|
run-name: Build docker image and publish to registry
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: https://github.com/actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: https://github.com/docker/setup-buildx-action@v3
|
|
with:
|
|
driver-opts: image=moby/buildkit:latest
|
|
install: true
|
|
network: host
|
|
buildkitd-config-inline: |
|
|
[registry."10.0.2.28:222"]
|
|
http = true
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
uses: https://github.com/docker/login-action@v3
|
|
with:
|
|
registry: 10.0.2.28:222
|
|
username: lino
|
|
password: ${{ secrets.REGISTRY_PASS }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: https://github.com/docker/metadata-action@v5
|
|
with:
|
|
images: 10.0.2.28:222/${{ gitea.repository }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,prefix={{branch}}-
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push Docker image
|
|
uses: https://github.com/docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|