From c778e9071f4a823bfd5981913bf09e486c743435 Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:25:37 +0000 Subject: [PATCH] Convert IMAGE_NAME to lowercase in GH Actions workflows --- .github/workflows/docker-build.yml | 10 +++++++--- .github/workflows/docker-manual.yml | 10 +++++++--- .github/workflows/docker-master.yml | 8 ++++++-- .github/workflows/docker-pr.yml | 2 +- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index f13c5410..1c67a3ce 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -43,6 +43,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Convert repo name to lowercase + id: github_repo_lowercase + run: INPUT=${{ env.IMAGE_NAME }}; echo "IMAGE_LOWERCASE=${INPUT,,}">>${GITHUB_OUTPUT} + - name: Extract tag version from branch name id: extract_tag_version run: | @@ -56,7 +60,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ steps.github_repo_lowercase.outputs.IMAGE_LOWERCASE }} labels: | org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/blob/${{ env.BRANCH }}/README.md org.opencontainers.image.version=${{ env.VERSION }} @@ -68,7 +72,7 @@ jobs: uses: docker/build-push-action@v6 with: push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} + tags: ${{ env.REGISTRY }}/${{ steps.github_repo_lowercase.outputs.IMAGE_LOWERCASE }}:${{ env.VERSION }} labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} context: ${{ env.CONTEXT }}${{ env.DOCKERFILE_PATH }} @@ -86,7 +90,7 @@ jobs: TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db with: - image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} + image-ref: ${{ env.REGISTRY }}/${{ steps.github_repo_lowercase.outputs.IMAGE_LOWERCASE }}:${{ env.VERSION }} format: sarif output: trivy-results.sarif diff --git a/.github/workflows/docker-manual.yml b/.github/workflows/docker-manual.yml index 40e1bdbe..a3bb38e8 100644 --- a/.github/workflows/docker-manual.yml +++ b/.github/workflows/docker-manual.yml @@ -33,6 +33,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Convert to lowercase + id: github_repo_lowercase + run: INPUT=${{ env.IMAGE_NAME }}; echo "IMAGE_LOWERCASE=${INPUT,,}">>${GITHUB_OUTPUT} + - name: Extract tag version from branch name id: extract_tag_version run: | @@ -46,7 +50,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ steps.github_repo_lowercase.outputs.IMAGE_LOWERCASE }} labels: | org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/blob/${{ env.BRANCH }}/README.md org.opencontainers.image.version=${{ env.VERSION }} @@ -58,7 +62,7 @@ jobs: uses: docker/build-push-action@v6 with: push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} + tags: ${{ env.REGISTRY }}/${{ steps.github_repo_lowercase.outputs.IMAGE_LOWERCASE }}:${{ env.VERSION }} labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} context: ${{ env.CONTEXT }}${{ env.DOCKERFILE_PATH }} @@ -76,7 +80,7 @@ jobs: TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db with: - image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} + image-ref: ${{ env.REGISTRY }}/${{ steps.github_repo_lowercase.outputs.IMAGE_LOWERCASE }}:${{ env.VERSION }} format: sarif output: trivy-results.sarif diff --git a/.github/workflows/docker-master.yml b/.github/workflows/docker-master.yml index 49687428..333bd463 100644 --- a/.github/workflows/docker-master.yml +++ b/.github/workflows/docker-master.yml @@ -38,6 +38,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Convert repo name to lowercase + id: github_repo_lowercase + run: INPUT=${{ env.IMAGE_NAME }}; echo "IMAGE_LOWERCASE=${INPUT,,}">>${GITHUB_OUTPUT} + - name: Get highest ckan branch excluding -dev id: getbranch run: echo "VERSION=$(git branch -r | grep -o 'ckan-[0-9]*\.[0-9]*\.[0-9]*[^-dev]$' | sort -V | tail -n 1)" >> $GITHUB_ENV @@ -46,7 +50,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ steps.github_repo_lowercase.outputs.IMAGE_LOWERCASE }} labels: | org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/blob/${{ env.BRANCH }}/README.md org.opencontainers.image.version=${{ env.VERSION }} @@ -58,7 +62,7 @@ jobs: uses: docker/build-push-action@v6 with: push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} + tags: ${{ env.REGISTRY }}/${{ steps.github_repo_lowercase.outputs.IMAGE_LOWERCASE }}:${{ env.VERSION }} labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} context: ${{ env.CONTEXT }}${{ env.DOCKERFILE_PATH }} diff --git a/.github/workflows/docker-pr.yml b/.github/workflows/docker-pr.yml index ccd46a79..fc84bb17 100644 --- a/.github/workflows/docker-pr.yml +++ b/.github/workflows/docker-pr.yml @@ -11,7 +11,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ckan-docker + IMAGE_NAME: ckan-docker-bne CONTEXT: . BRANCH: ${{ github.head_ref }} DOCKERFILE_PATH: /ckan