Skip to content

Commit

Permalink
lowercase the repo name in workflows for use as the container name
Browse files Browse the repository at this point in the history
It's not possible to push a mixed-case container name to a registry.
Let's lowercase the repo name before using it as a container name.
  • Loading branch information
jhrozek committed Mar 5, 2024
1 parent 7d5db0d commit d812e82
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 32 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build-image-signed-cosign-malicious.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
Expand Down Expand Up @@ -44,13 +43,17 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- id: lower-repo
run: |
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:daily
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest,ghcr.io/${{ env.IMAGE_NAME }}:daily
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -60,5 +63,5 @@ jobs:
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: |
echo "ghcr.io/${{ github.repository }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
echo "ghcr.io/${{ github.repository }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}
echo "ghcr.io/${{ env.IMAGE_NAME }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
echo "ghcr.io/${{ env.IMAGE_NAME }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}
9 changes: 6 additions & 3 deletions .github/workflows/build-image-signed-cosign-static-copied.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
Expand Down Expand Up @@ -40,12 +39,16 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- id: lower-repo
run: |
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
push: true
tags: ghcr.io/${{ github.repository }}:static
tags: ghcr.io/${{ env.IMAGE_NAME }}:static
context: .
file : Dockerfile.static

Expand All @@ -54,4 +57,4 @@ jobs:
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: |
echo "ghcr.io/${{ github.repository }}:static" | xargs -I {} cosign sign --yes {}@${DIGEST}
echo "ghcr.io/${{ env.IMAGE_NAME }}:static" | xargs -I {} cosign sign --yes {}@${DIGEST}
9 changes: 6 additions & 3 deletions .github/workflows/build-image-signed-cosign-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
Expand Down Expand Up @@ -40,12 +39,16 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- id: lower-repo
run: |
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
push: true
tags: ghcr.io/${{ github.repository }}:static
tags: ghcr.io/${{ env.IMAGE_NAME }}:static
context: .
file : Dockerfile.static

Expand All @@ -54,4 +57,4 @@ jobs:
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: |
echo "ghcr.io/${{ github.repository }}:static" | xargs -I {} cosign sign --yes {}@${DIGEST}
echo "ghcr.io/${{ env.IMAGE_NAME }}:static" | xargs -I {} cosign sign --yes {}@${DIGEST}
11 changes: 7 additions & 4 deletions .github/workflows/build-image-signed-cosign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
Expand Down Expand Up @@ -40,13 +39,17 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- id: lower-repo
run: |
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:daily
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest,ghcr.io/${{ env.IMAGE_NAME }}:daily
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -56,5 +59,5 @@ jobs:
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: |
echo "ghcr.io/${{ github.repository }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
echo "ghcr.io/${{ github.repository }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}
echo "ghcr.io/${{ env.IMAGE_NAME }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
echo "ghcr.io/${{ env.IMAGE_NAME }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}
8 changes: 6 additions & 2 deletions .github/workflows/build-image-signed-ghat-malicious.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: lower-repo
run: |
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push image
id: push-step
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest
context: .

- name: Attest image
uses: github-early-access/generate-build-provenance@main
with:
subject-name: ghcr.io/${{ github.repository }}
subject-name: ghcr.io/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push-step.outputs.digest }}
push-to-registry: true
8 changes: 6 additions & 2 deletions .github/workflows/build-image-signed-ghat-static-copied.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: lower-repo
run: |
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push image
id: push-step
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
push: true
tags: ghcr.io/${{ github.repository }}:static
tags: ghcr.io/${{ env.IMAGE_NAME }}:static
context: .
file : Dockerfile.static

- name: Attest image
uses: github-early-access/generate-build-provenance@main
with:
subject-name: ghcr.io/${{ github.repository }}
subject-name: ghcr.io/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push-step.outputs.digest }}
push-to-registry: true
8 changes: 6 additions & 2 deletions .github/workflows/build-image-signed-ghat-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: lower-repo
run: |
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push image
id: push-step
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
push: true
tags: ghcr.io/${{ github.repository }}:static
tags: ghcr.io/${{ env.IMAGE_NAME }}:static
context: .
file : Dockerfile.static

- name: Attest image
uses: github-early-access/generate-build-provenance@main
with:
subject-name: ghcr.io/${{ github.repository }}
subject-name: ghcr.io/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push-step.outputs.digest }}
push-to-registry: true
8 changes: 6 additions & 2 deletions .github/workflows/build-image-signed-ghat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: lower-repo
run: |
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and push image
id: push-step
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest
context: .

- name: Attest image
uses: github-early-access/generate-build-provenance@main
with:
subject-name: ghcr.io/${{ github.repository }}
subject-name: ghcr.io/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push-step.outputs.digest }}
push-to-registry: true
16 changes: 6 additions & 10 deletions .github/workflows/build-image-unsigned.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
Expand Down Expand Up @@ -34,6 +33,10 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: lower-repo
run: |
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
Expand All @@ -46,14 +49,7 @@ jobs:
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:daily
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest,ghcr.io/${{ env.IMAGE_NAME }}:daily
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# - name: Sign the published Docker image
# env:
# DIGEST: ${{ steps.build-and-push.outputs.digest }}
# run: |
# echo "ghcr.io/${{ github.repository }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
# echo "ghcr.io/${{ github.repository }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}
cache-to: type=gha,mode=max

0 comments on commit d812e82

Please sign in to comment.