docker-clang-format #49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
jobs: | |
publish-image: | |
name: clang-format ${{ matrix.version-pair.version }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
version-pair: | |
- {version: "16", ubuntu: "lunar"} | |
steps: | |
- uses: actions/checkout@v3 | |
- 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}}/lockshaw/${{ 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@v4 | |
with: | |
go-version: '^1.17' | |
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 |