56 lines
1.8 KiB
YAML
56 lines
1.8 KiB
YAML
|
name: Build Docker image
|
||
|
run-name: ${{ gitea.actor }} is building a new image 🚀
|
||
|
on:
|
||
|
# schedule:
|
||
|
# - cron: "0 10 * * *"
|
||
|
push:
|
||
|
branches:
|
||
|
- "**"
|
||
|
tags:
|
||
|
- "v*.*.*"
|
||
|
pull_request:
|
||
|
branches:
|
||
|
- "main"
|
||
|
|
||
|
jobs:
|
||
|
build:
|
||
|
runs-on: ubuntu-docker
|
||
|
steps:
|
||
|
- name: Check out repository code
|
||
|
uses: actions/checkout@v4
|
||
|
- name: Set up Docker Buildx
|
||
|
uses: docker/setup-buildx-action@v3
|
||
|
- name: Generate image tags
|
||
|
# https://docs.docker.com/build/ci/github-actions/manage-tags-labels/
|
||
|
id: meta
|
||
|
uses: docker/metadata-action@v5
|
||
|
with:
|
||
|
# list of Docker images to use as base name for tags
|
||
|
images: |
|
||
|
git.hollander.online/${{ gitea.repository_owner }}/${{ gitea.event.repository.name }}
|
||
|
# generate Docker tags based on the following events/attributes
|
||
|
tags: |
|
||
|
type=schedule
|
||
|
type=ref,event=branch
|
||
|
type=ref,event=pr
|
||
|
type=semver,pattern={{version}}
|
||
|
type=semver,pattern={{major}}.{{minor}}
|
||
|
type=semver,pattern={{major}}
|
||
|
type=sha
|
||
|
- name: Login to registry
|
||
|
if: gitea.event_name != 'pull_request'
|
||
|
uses: docker/login-action@v3
|
||
|
with:
|
||
|
registry: git.hollander.online
|
||
|
username: ${{ gitea.repository_owner }}
|
||
|
password: ${{ secrets.CI_PACKAGES_RW }}
|
||
|
- name: Build and push
|
||
|
uses: docker/build-push-action@v5
|
||
|
with:
|
||
|
context: .
|
||
|
push: ${{ gitea.event_name != 'pull_request' }}
|
||
|
tags: ${{ steps.meta.outputs.tags }}
|
||
|
labels: ${{ steps.meta.outputs.labels }}
|
||
|
platforms: linux/arm64,linux/amd64
|
||
|
- name: Cleanup old images
|
||
|
run: docker system prune -f
|