Add container build workflow

This commit is contained in:
Pieter Hollander 2024-02-21 11:23:27 +01:00
parent 9756e25f89
commit 62050699f2
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

View file

@ -0,0 +1,58 @@
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: echo job info
run: echo "🎉 This job was automatically triggered by a ${{ gitea.event_name }} event and running on a ${{ runner.os }} repo:branch:${{ gitea.repository }}:${{ gitea.ref }}."
- 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