caddy/.forgejo/workflows/build.yaml
Marko Korhonen 16299cb5ee
All checks were successful
Build Docker image / Build image (push) Successful in 2m54s
Bump version
2024-06-04 23:59:31 +03:00

62 lines
2 KiB
YAML

name: Build Docker image
on:
push:
schedule:
- cron: "0 10 * * *"
jobs:
build_image:
name: Build image
runs-on: docker
if: env.SCHEDULED == 'true' || !contains(github.event.commits[0].message, '[skip ci]')
env:
VERSION: 2.8
SCHEDULED: ${{ github.event_name == 'schedule' }}
PUSHED: ${{ github.event_name == 'push' }}
REGISTRY: git.korhonen.cc
REPO: ${{ env.REGISTRY }}/functionalhacker/caddy
steps:
- name: Check if update available
if: env.SCHEDULED == 'true'
id: check
uses: https://github.com/ClementTsang/docker-check-base-image-diff@v0.0.2
with:
base-image: docker://caddy:${{ env.VERSION }}
derived-image: docker://${{ env.REPO }}:latest
- name: Check result
if: env.SCHEDULED == 'true'
run: echo "Needs updating = ${{ steps.check.outputs.differs }}"
- name: Set up Docker Buildx
if: env.PUSHED == 'true' || steps.check.outputs.differs == 'true'
uses: docker/setup-buildx-action@v3
- name: Login to Docker registry
if: env.PUSHED == 'true' || steps.check.outputs.differs == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Get point release
id: point_release
if: env.PUSHED == 'true' || steps.check.outputs.differs == 'true'
run: |
VERSION="$(skopeo list-tags docker://caddy | jq -r '[.Tags[] | select(test("^${{ VERSION }}.[0-9]$"))] | last')"
echo "Point release: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build and push image
if: env.PUSHED == 'true' || steps.check.outputs.differs == 'true'
uses: docker/build-push-action@v5
with:
push: true
build-args: VERSION=${{ env.VERSION }}
tags: |
${{ env.REPO }}:latest
${{ env.REPO }}:${{ env.VERSION }}