Skip to content

docker-clang-format #1026

docker-clang-format

docker-clang-format #1026

name: docker-clang-format
on:
push:
branches:
- 'main'
paths:
- 'clang-format-docker/**'
- '.github/workflows/clang-format-image.yml'
workflow_dispatch:
schedule:
- cron: '5 4 * * *' # Daily at 04:05
defaults:
run:
shell: bash
env:
REGISTRY: ghcr.io
IMAGE_NAME: clang-format
permissions:
contents: read
packages: write
jobs:
publish-image:
name: clang-format ${{ matrix.version-pair.version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version-pair:
- {version: "18", ubuntu: "noble"}
- {version: "17", ubuntu: "noble"}
- {version: "16", ubuntu: "noble"}
- {version: "15", ubuntu: "noble"}
- {version: "14", ubuntu: "noble"}
- {version: "13", ubuntu: "jammy"}
- {version: "12", ubuntu: "jammy"}
- {version: "11", ubuntu: "jammy"}
- {version: "10", ubuntu: "focal"}
- {version: "9", ubuntu: "focal"}
- {version: "8", ubuntu: "focal"}
- {version: "7", ubuntu: "focal"}
- {version: "6.0", ubuntu: "focal"}
- {version: "5.0", ubuntu: "bionic"}
- {version: "4.0", ubuntu: "bionic"}
- {version: "3.9", ubuntu: "bionic"}
steps:
- uses: actions/checkout@v4
- name: Parse version tags
run: |
VERSION="${{ matrix.version-pair.version }}"
MAJOR_VERSION="${VERSION%%.*}"
echo "MAJOR_VERSION=$MAJOR_VERSION" >> "$GITHUB_ENV"
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: "clang-format-docker/Dockerfile"
push: true
tags: ${{ env.REGISTRY}}/jidicula/${{ env.IMAGE_NAME}}:${{ env.MAJOR_VERSION }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"UBUNTU_VERSION=${{ matrix.version-pair.ubuntu }}"
"CLANG_FORMAT_VERSION=${{ matrix.version-pair.version }}"
clean-untagged-images:
needs: publish-image
name: Clean untagged images
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: '^1.22'
check-latest: true
- name: Install ghcr-cleaner
run: go install github.com/jidicula/ghcr-cleaner@latest
- name: Run ghcr-cleaner
run: ghcr-cleaner --token "${{ secrets.GHCR_DELETE_TOKEN }}" --packagename clang-format