Bump actions/cache from 5 to 6 (#350) #365
This file contains hidden or 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 Image | |
| on: | |
| pull_request: | |
| branches: [ master ] | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - "*.*.*" | |
| jobs: | |
| buildx: | |
| runs-on: ubuntu-latest | |
| #strategy: | |
| # fail-fast: false | |
| # max-parallel: 2 | |
| # matrix: | |
| # # Not all for time waste reasons | |
| # platform: [ "linux/arm64", "linux/arm/v7", "linux/amd64" ] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| # this writes the tag name into GIT_TAG_NAME | |
| - name: Get tag name | |
| uses: little-core-labs/get-git-tag@v3.0.2 | |
| # https://github.com/docker/setup-qemu-action | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| # https://github.com/docker/setup-buildx-action | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v4 | |
| #with: | |
| # install: true | |
| - name: Cache Docker layers | |
| uses: actions/cache@v6 | |
| id: cache | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx- | |
| - name: Inspect builder | |
| run: | | |
| echo "Name: ${{ steps.buildx.outputs.name }}" | |
| echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" | |
| echo "Status: ${{ steps.buildx.outputs.status }}" | |
| echo "Flags: ${{ steps.buildx.outputs.flags }}" | |
| echo "Platforms: ${{ steps.buildx.outputs.platforms }}" | |
| - name: Prepare | |
| id: prepare | |
| run: | | |
| DOCKER_IMAGE=markusressel/barcode-server | |
| # compare with support in base image: https://hub.docker.com/_/python | |
| # orjson supports armv7 since 3.6.7, see https://github.com/ijl/orjson/releases/tag/3.6.7 | |
| DOCKER_PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7 | |
| VERSION=latest | |
| TAGS="--tag ${DOCKER_IMAGE}:${VERSION}" | |
| if [[ $GIT_TAG_NAME =~ ^v?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
| VERSION=${GIT_TAG_NAME} | |
| TAGS="$TAGS --tag ${DOCKER_IMAGE}:${VERSION}" | |
| fi | |
| echo ::set-output name=docker_image::${DOCKER_IMAGE} | |
| echo ::set-output name=version::${VERSION} | |
| echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ | |
| --build-arg VERSION=${VERSION} \ | |
| --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | |
| --build-arg VCS_REF=${GITHUB_SHA::8} \ | |
| --cache-from "type=local,src=/tmp/.buildx-cache" \ | |
| --cache-to "type=local,dest=/tmp/.buildx-cache" \ | |
| ${TAGS} --file Dockerfile . | |
| - name: Build | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} | |
| - name: Login to DockerHub Registry | |
| if: github.event_name == 'push' | |
| run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
| - name: Build & Push | |
| if: github.event_name == 'push' | |
| run: | | |
| docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} |