Skip to content

feat: add support for a persistent ccache #1719

feat: add support for a persistent ccache

feat: add support for a persistent ccache #1719

Workflow file for this run

---
name: build
on:
push:
pull_request:
workflow_dispatch:
env:
DOCKERHUB_REPOSITORY: ksmanis/gentoo-distcc
DOCKERHUB_USERNAME: ksmanis
jobs:
images:
strategy:
fail-fast: false
matrix:
arch: ["386", "amd64", "arm/v6", "arm/v7", "arm64", "ppc64le"]
target: ["tcp", "ssh"]
name: ${{ matrix.arch }}:${{ matrix.target }} image
runs-on: ubuntu-latest
continue-on-error: true
outputs:
manifests: ${{ steps.output.outputs.manifests }}
steps:
- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Prepare build variables
id: prep
run: |
{
echo "qemu_platform=$(echo "${{ matrix.arch }}" | cut -d '/' -f 1)"
echo "stage3_version=$(sed -n 's#^FROM ksmanis/stage3:\(\S\+\).*#\1#p' Dockerfile)"
echo "tag=$(echo "${{ matrix.arch }}" | tr -d '/')-${{ matrix.target }}"
} >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
if: matrix.arch != '386' && matrix.arch != 'amd64'
with:
platforms: ${{ steps.prep.outputs.qemu_platform }}
- name: Set up buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
- name: Define Docker metadata
id: docker-metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5
with:
images: |
docker.io/${{ env.DOCKERHUB_REPOSITORY }}
ghcr.io/${{ env.DOCKERHUB_REPOSITORY }}
flavor: |
latest=false
labels: |
org.opencontainers.image.title=gentoo-distcc
org.opencontainers.image.authors=Konstantinos Smanis <konstantinos.smanis@gmail.com>
tags: |
type=ref,event=branch,prefix=${{ steps.prep.outputs.tag }}-,suffix=-{{sha}}
type=ref,event=branch,prefix=${{ steps.prep.outputs.tag }}-
type=ref,event=pr,prefix=${{ steps.prep.outputs.tag }}-pr-,suffix=-{{sha}}
type=ref,event=pr,prefix=${{ steps.prep.outputs.tag }}-pr-
type=raw,value=${{ steps.prep.outputs.tag }}-${{ steps.prep.outputs.stage3_version }},enable={{is_default_branch}}
type=raw,value=${{ steps.prep.outputs.tag }},enable={{is_default_branch}}
- name: Build image
id: build
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6
with:
context: .
labels: ${{ steps.docker-metadata.outputs.labels }}
tags: ${{ steps.docker-metadata.outputs.tags }}
platforms: linux/${{ matrix.arch }}
target: distcc-${{ matrix.target }}
load: true
- name: Inspect image
run: |
docker image inspect ${{ steps.build.outputs.imageid }}
- name: Build test image
id: build-test
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6
with:
context: .
platforms: linux/${{ matrix.arch }}
target: distcc-${{ matrix.target }}-test
load: true
- name: Test distcc
env:
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }}
IMAGE: ${{ steps.build.outputs.imageid }}
TEST_IMAGE: ${{ steps.build-test.outputs.imageid }}
run: |
docker compose -f docker-compose.test.yml -p test up \
--exit-code-from distcc-${{ matrix.target }}-client \
distcc-${{ matrix.target }}-client distcc-${{ matrix.target }}-server
- name: Log in to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
run: |
docker push --all-tags "docker.io/${DOCKERHUB_REPOSITORY}"
docker push --all-tags "ghcr.io/${DOCKERHUB_REPOSITORY}"
- name: Prepare outputs
id: output
run: |
echo "manifests=$(echo "${DOCKER_METADATA_OUTPUT_JSON}" | jq -cf manifests.jq)" >> "$GITHUB_OUTPUT"
manifests:
needs: images
strategy:
fail-fast: false
matrix:
manifest: ${{ fromJson(needs.images.outputs.manifests) }}
name: ${{ matrix.manifest.registry }}:${{ matrix.manifest.tag }} manifest
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Log in to Docker Hub
if: matrix.manifest.registry == 'docker.io'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container registry
if: matrix.manifest.registry == 'ghcr.io'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push manifest list
env:
REPO: ${{ matrix.manifest.repo }}
TAG: ${{ matrix.manifest.tag }}
run: |
./build-manifest.sh