Align workflow with debshots pattern: docker CLI, permissions, layer caching
All checks were successful
Build and push container image / build-and-push (push) Successful in 6m0s

This commit is contained in:
Christoph Haas 2026-08-22 11:51:02 +02:00
parent 5e45dd358a
commit fc04ea7900

View file

@ -1,3 +1,10 @@
# =============================================================================
# Forgejo Actions workflow to build and push Docker image
# =============================================================================
# Triggered on push to main. Pushes :latest plus :$SHA tags; the SHA matches
# what the service reports at GET /version.
# -----------------------------------------------------------------------------
name: Build and push container image name: Build and push container image
on: on:
@ -10,21 +17,30 @@ env:
jobs: jobs:
build-and-push: build-and-push:
runs-on: docker runs-on: docker
permissions:
contents: read
packages: write
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Buildx - name: Install Docker CLI
run: |
apt-get update -qq
apt-get install -y --no-install-recommends docker.io
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to Forgejo registry - name: Login to Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: git.workaround.org registry: git.workaround.org
username: chaas username: ${{ github.actor }}
password: ${{ secrets.FORGEJO_TOKEN }} password: ${{ secrets.FORGEJO_TOKEN }}
- name: Build and push - name: Build and Push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: . context: .
@ -34,3 +50,5 @@ jobs:
tags: | tags: |
${{ env.IMAGE }}:latest ${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ github.sha }} ${{ env.IMAGE }}:${{ github.sha }}
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max