Skip to content

Commit d812e82

Browse files
committed
lowercase the repo name in workflows for use as the container name
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.
1 parent 7d5db0d commit d812e82

9 files changed

+56
-32
lines changed

.github/workflows/build-image-signed-cosign-malicious.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44

55
env:
66
REGISTRY: ghcr.io
7-
IMAGE_NAME: ${{ github.repository }}
87

98
jobs:
109
build:
@@ -44,13 +43,17 @@ jobs:
4443
with:
4544
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4645

46+
- id: lower-repo
47+
run: |
48+
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
49+
4750
- name: Build and push Docker image
4851
id: build-and-push
4952
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
5053
with:
5154
context: .
5255
push: ${{ github.event_name != 'pull_request' }}
53-
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:daily
56+
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest,ghcr.io/${{ env.IMAGE_NAME }}:daily
5457
labels: ${{ steps.meta.outputs.labels }}
5558
cache-from: type=gha
5659
cache-to: type=gha,mode=max
@@ -60,5 +63,5 @@ jobs:
6063
env:
6164
DIGEST: ${{ steps.build-and-push.outputs.digest }}
6265
run: |
63-
echo "ghcr.io/${{ github.repository }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
64-
echo "ghcr.io/${{ github.repository }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}
66+
echo "ghcr.io/${{ env.IMAGE_NAME }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
67+
echo "ghcr.io/${{ env.IMAGE_NAME }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}

.github/workflows/build-image-signed-cosign-static-copied.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44

55
env:
66
REGISTRY: ghcr.io
7-
IMAGE_NAME: ${{ github.repository }}
87

98
jobs:
109
build:
@@ -40,12 +39,16 @@ jobs:
4039
with:
4140
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4241

42+
- id: lower-repo
43+
run: |
44+
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
45+
4346
- name: Build and push Docker image
4447
id: build-and-push
4548
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
4649
with:
4750
push: true
48-
tags: ghcr.io/${{ github.repository }}:static
51+
tags: ghcr.io/${{ env.IMAGE_NAME }}:static
4952
context: .
5053
file : Dockerfile.static
5154

@@ -54,4 +57,4 @@ jobs:
5457
env:
5558
DIGEST: ${{ steps.build-and-push.outputs.digest }}
5659
run: |
57-
echo "ghcr.io/${{ github.repository }}:static" | xargs -I {} cosign sign --yes {}@${DIGEST}
60+
echo "ghcr.io/${{ env.IMAGE_NAME }}:static" | xargs -I {} cosign sign --yes {}@${DIGEST}

.github/workflows/build-image-signed-cosign-static.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44

55
env:
66
REGISTRY: ghcr.io
7-
IMAGE_NAME: ${{ github.repository }}
87

98
jobs:
109
build:
@@ -40,12 +39,16 @@ jobs:
4039
with:
4140
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4241

42+
- id: lower-repo
43+
run: |
44+
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
45+
4346
- name: Build and push Docker image
4447
id: build-and-push
4548
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
4649
with:
4750
push: true
48-
tags: ghcr.io/${{ github.repository }}:static
51+
tags: ghcr.io/${{ env.IMAGE_NAME }}:static
4952
context: .
5053
file : Dockerfile.static
5154

@@ -54,4 +57,4 @@ jobs:
5457
env:
5558
DIGEST: ${{ steps.build-and-push.outputs.digest }}
5659
run: |
57-
echo "ghcr.io/${{ github.repository }}:static" | xargs -I {} cosign sign --yes {}@${DIGEST}
60+
echo "ghcr.io/${{ env.IMAGE_NAME }}:static" | xargs -I {} cosign sign --yes {}@${DIGEST}

.github/workflows/build-image-signed-cosign.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44

55
env:
66
REGISTRY: ghcr.io
7-
IMAGE_NAME: ${{ github.repository }}
87

98
jobs:
109
build:
@@ -40,13 +39,17 @@ jobs:
4039
with:
4140
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4241

42+
- id: lower-repo
43+
run: |
44+
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
45+
4346
- name: Build and push Docker image
4447
id: build-and-push
4548
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
4649
with:
4750
context: .
4851
push: ${{ github.event_name != 'pull_request' }}
49-
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:daily
52+
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest,ghcr.io/${{ env.IMAGE_NAME }}:daily
5053
labels: ${{ steps.meta.outputs.labels }}
5154
cache-from: type=gha
5255
cache-to: type=gha,mode=max
@@ -56,5 +59,5 @@ jobs:
5659
env:
5760
DIGEST: ${{ steps.build-and-push.outputs.digest }}
5861
run: |
59-
echo "ghcr.io/${{ github.repository }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
60-
echo "ghcr.io/${{ github.repository }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}
62+
echo "ghcr.io/${{ env.IMAGE_NAME }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
63+
echo "ghcr.io/${{ env.IMAGE_NAME }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}

.github/workflows/build-image-signed-ghat-malicious.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,21 @@ jobs:
2525
username: ${{ github.actor }}
2626
password: ${{ secrets.GITHUB_TOKEN }}
2727

28+
- id: lower-repo
29+
run: |
30+
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
31+
2832
- name: Build and push image
2933
id: push-step
3034
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
3135
with:
3236
push: true
33-
tags: ghcr.io/${{ github.repository }}:latest
37+
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest
3438
context: .
3539

3640
- name: Attest image
3741
uses: github-early-access/generate-build-provenance@main
3842
with:
39-
subject-name: ghcr.io/${{ github.repository }}
43+
subject-name: ghcr.io/${{ env.IMAGE_NAME }}
4044
subject-digest: ${{ steps.push-step.outputs.digest }}
4145
push-to-registry: true

.github/workflows/build-image-signed-ghat-static-copied.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,22 @@ jobs:
2121
username: ${{ github.actor }}
2222
password: ${{ secrets.GITHUB_TOKEN }}
2323

24+
- id: lower-repo
25+
run: |
26+
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
27+
2428
- name: Build and push image
2529
id: push-step
2630
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
2731
with:
2832
push: true
29-
tags: ghcr.io/${{ github.repository }}:static
33+
tags: ghcr.io/${{ env.IMAGE_NAME }}:static
3034
context: .
3135
file : Dockerfile.static
3236

3337
- name: Attest image
3438
uses: github-early-access/generate-build-provenance@main
3539
with:
36-
subject-name: ghcr.io/${{ github.repository }}
40+
subject-name: ghcr.io/${{ env.IMAGE_NAME }}
3741
subject-digest: ${{ steps.push-step.outputs.digest }}
3842
push-to-registry: true

.github/workflows/build-image-signed-ghat-static.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,22 @@ jobs:
2121
username: ${{ github.actor }}
2222
password: ${{ secrets.GITHUB_TOKEN }}
2323

24+
- id: lower-repo
25+
run: |
26+
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
27+
2428
- name: Build and push image
2529
id: push-step
2630
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
2731
with:
2832
push: true
29-
tags: ghcr.io/${{ github.repository }}:static
33+
tags: ghcr.io/${{ env.IMAGE_NAME }}:static
3034
context: .
3135
file : Dockerfile.static
3236

3337
- name: Attest image
3438
uses: github-early-access/generate-build-provenance@main
3539
with:
36-
subject-name: ghcr.io/${{ github.repository }}
40+
subject-name: ghcr.io/${{ env.IMAGE_NAME }}
3741
subject-digest: ${{ steps.push-step.outputs.digest }}
3842
push-to-registry: true

.github/workflows/build-image-signed-ghat.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@ jobs:
2121
username: ${{ github.actor }}
2222
password: ${{ secrets.GITHUB_TOKEN }}
2323

24+
- id: lower-repo
25+
run: |
26+
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
27+
2428
- name: Build and push image
2529
id: push-step
2630
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
2731
with:
2832
push: true
29-
tags: ghcr.io/${{ github.repository }}:latest
33+
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest
3034
context: .
3135

3236
- name: Attest image
3337
uses: github-early-access/generate-build-provenance@main
3438
with:
35-
subject-name: ghcr.io/${{ github.repository }}
39+
subject-name: ghcr.io/${{ env.IMAGE_NAME }}
3640
subject-digest: ${{ steps.push-step.outputs.digest }}
3741
push-to-registry: true

.github/workflows/build-image-unsigned.yml

+6-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44

55
env:
66
REGISTRY: ghcr.io
7-
IMAGE_NAME: ${{ github.repository }}
87

98
jobs:
109
build:
@@ -34,6 +33,10 @@ jobs:
3433
username: ${{ github.actor }}
3534
password: ${{ secrets.GITHUB_TOKEN }}
3635

36+
- id: lower-repo
37+
run: |
38+
echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
39+
3740
- name: Extract Docker metadata
3841
id: meta
3942
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
@@ -46,14 +49,7 @@ jobs:
4649
with:
4750
context: .
4851
push: ${{ github.event_name != 'pull_request' }}
49-
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:daily
52+
tags: ghcr.io/${{ env.IMAGE_NAME }}:latest,ghcr.io/${{ env.IMAGE_NAME }}:daily
5053
labels: ${{ steps.meta.outputs.labels }}
5154
cache-from: type=gha
52-
cache-to: type=gha,mode=max
53-
54-
# - name: Sign the published Docker image
55-
# env:
56-
# DIGEST: ${{ steps.build-and-push.outputs.digest }}
57-
# run: |
58-
# echo "ghcr.io/${{ github.repository }}:daily" | xargs -I {} cosign sign --yes {}@${DIGEST}
59-
# echo "ghcr.io/${{ github.repository }}:latest" | xargs -I {} cosign sign --yes {}@${DIGEST}
55+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)