Skip to content

Commit e7d51db

Browse files
ci: Make able to run workflow in forks with uppercase in names (#782)
### Description of your changes Deal with ``` ERROR: invalid tag "ghcr.io/MaxymVlasov/pre-commit-terraform-712:latest": repository name must be lowercase ``` Found during testing changes for OSSF score improvement - as I need to test all workflows without disrupting main repo --------- Co-authored-by: George L. Yermulnik <[email protected]>
1 parent 917f4d0 commit e7d51db

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

.github/workflows/build-image-test.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ jobs:
3232
.github/workflows/build-image-test.yaml
3333
tools/*.sh
3434
35+
- name: Set IMAGE environment variable
36+
# Lowercase the org/repo name to allow for workflow to run in forks,
37+
# which owners have uppercase letters in username
38+
run: >-
39+
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}:${{ env.IMAGE_TAG }}"
40+
>> $GITHUB_ENV
3541
- name: Set up QEMU
3642
if: matrix.os != 'ubuntu-latest' || matrix.arch != 'amd64'
3743
# yamllint disable-line rule:line-length
@@ -56,8 +62,7 @@ jobs:
5662
linux/${{ matrix.arch }}
5763
push: false
5864
load: true
59-
tags: |
60-
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
65+
tags: ${{ env.IMAGE }}
6166
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
6267
provenance: false
6368
secrets: |
@@ -68,15 +73,15 @@ jobs:
6873
# yamllint disable-line rule:line-length
6974
uses: plexsystems/container-structure-test-action@c0a028aa96e8e82ae35be556040340cbb3e280ca # v0.3.0
7075
with:
71-
image: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
76+
image: ${{ env.IMAGE }}
7277
config: .github/.container-structure-test-config.yaml
7378

7479
- name: Dive - check image for waste files
7580
if: steps.changed-files-specific.outputs.any_changed == 'true'
7681
# yamllint disable-line rule:line-length
7782
uses: MaxymVlasov/dive-action@379af3fc636888ada5899c997e8b52db6ad45023 # v1.0.1
7883
with:
79-
image: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
84+
image: ${{ env.IMAGE }}
8085
config-file: ${{ github.workspace }}/.github/.dive-ci.yaml
8186
github-token: ${{ secrets.GITHUB_TOKEN }}
8287

@@ -95,8 +100,7 @@ jobs:
95100
INSTALL_ALL=true
96101
platforms: linux/amd64,linux/arm64
97102
push: false
98-
tags: |
99-
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
103+
tags: ${{ env.IMAGE }}
100104
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
101105
provenance: false
102106
secrets: |

.github/workflows/build-image.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737
|| echo 'latest'
3838
) >> $GITHUB_ENV
3939
40+
- name: Set IMAGE_REPO environment variable
41+
# Lowercase the org/repo name to allow for workflow to run in forks,
42+
# which owners have uppercase letters in username
43+
run: >-
44+
echo "IMAGE_REPO=ghcr.io/${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV
4045
- name: Set up Docker Buildx
4146
# yamllint disable-line rule:line-length
4247
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
@@ -52,8 +57,8 @@ jobs:
5257
platforms: linux/amd64,linux/arm64
5358
push: true
5459
tags: |
55-
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
56-
ghcr.io/${{ github.repository }}:latest
60+
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}
61+
${{ env.IMAGE_REPO }}:latest
5762
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
5863
provenance: false
5964
secrets: |
@@ -70,7 +75,7 @@ jobs:
7075
platforms: linux/amd64,linux/arm64
7176
push: true
7277
tags: |
73-
ghcr.io/${{ github.repository }}:nightly
78+
${{ env.IMAGE_REPO }}:nightly
7479
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
7580
provenance: false
7681
secrets: |

0 commit comments

Comments
 (0)