Skip to content

Commit

Permalink
Convert IMAGE_NAME to lowercase in GH Actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
mjanez authored Dec 4, 2024
1 parent 0f79657 commit c778e90
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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

Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/docker-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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

Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/docker-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c778e90

Please sign in to comment.