From f5b21cf664b474d402700c8ab8f17ff2c5e72037 Mon Sep 17 00:00:00 2001 From: Artem Yurchenko Date: Mon, 7 Oct 2024 16:47:09 +0200 Subject: [PATCH] refactor(ci): remove label from Dockerhub; use inline cache --- .github/workflows/build_and_push_docker_image.yml | 4 ++-- .github/workflows/validate_new_changes.yml | 12 ++++++++++-- Dockerfile | 4 ---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_and_push_docker_image.yml b/.github/workflows/build_and_push_docker_image.yml index e12e27c..b677d9b 100644 --- a/.github/workflows/build_and_push_docker_image.yml +++ b/.github/workflows/build_and_push_docker_image.yml @@ -49,5 +49,5 @@ jobs: push: true tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.CURRENT_COMMIT_SHORT_HASH }}" - cache-from: "type=gha" - cache-to: "type=gha,mode=max" + cache-from: "type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" + cache-to: "type=inline" diff --git a/.github/workflows/validate_new_changes.yml b/.github/workflows/validate_new_changes.yml index 19d9b8a..cb9b3a8 100644 --- a/.github/workflows/validate_new_changes.yml +++ b/.github/workflows/validate_new_changes.yml @@ -5,6 +5,7 @@ on: permissions: contents: "read" + packages: "read" env: REGISTRY: "ghcr.io" @@ -23,6 +24,13 @@ jobs: - name: "Set up Docker Buildx" uses: "docker/setup-buildx-action@v3" + - name: "Login to Docker registry" + uses: "docker/login-action@v3" + with: + registry: "${{ env.REGISTRY }}" + username: "${{ github.actor }}" + password: "${{ secrets.GITHUB_TOKEN }}" + - name: "Build YAML linter Docker image" uses: "docker/build-push-action@v6" with: @@ -30,8 +38,8 @@ jobs: load: true # NOTE: using another name to don't allow docker to download image from the internet in the next step. tags: "local/yaml-linter-pr:latest" - cache-from: "type=gha" - cache-to: "type=gha,mode=max" + cache-from: "type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" + cache-to: "type=inline" - name: "Run local YAML linter" run: "docker run --rm -v ${{ github.workspace }}:/linter_workdir/repo local/yaml-linter-pr:latest" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 55a30ff..5df2985 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,5 @@ FROM python:3.12.7-alpine -LABEL org.opencontainers.image.description="This image contains preconfigured \ -[YAML linter](https://github.com/adrienverge/yamllint). \ -This linter is used in Articola Tools organization's repositories to lint YAML files like GitHub Actions." - RUN pip install --no-cache-dir yamllint ADD ./ /linter_workdir