Skip to content

Commit 97d87f4

Browse files
committed
ci: Make able to run workflow in forks with uppercase in names
1 parent 917f4d0 commit 97d87f4

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ jobs:
3232
.github/workflows/build-image-test.yaml
3333
tools/*.sh
3434
35+
- name: Set IMAGE environment variable
36+
# Lowercase the repo name for make able to run workflow in forks,
37+
# which owners have uppercase letters in nickname
38+
run: >-
39+
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}:${{ env.IMAGE_TAG }}"
40+
>> $GITHUB_ENV
41+
3542
- name: Set up QEMU
3643
if: matrix.os != 'ubuntu-latest' || matrix.arch != 'amd64'
3744
# yamllint disable-line rule:line-length
@@ -56,8 +63,7 @@ jobs:
5663
linux/${{ matrix.arch }}
5764
push: false
5865
load: true
59-
tags: |
60-
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
66+
tags: ${{ env.IMAGE }}
6167
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
6268
provenance: false
6369
secrets: |
@@ -68,15 +74,15 @@ jobs:
6874
# yamllint disable-line rule:line-length
6975
uses: plexsystems/container-structure-test-action@c0a028aa96e8e82ae35be556040340cbb3e280ca # v0.3.0
7076
with:
71-
image: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
77+
image: ${{ env.IMAGE }}
7278
config: .github/.container-structure-test-config.yaml
7379

7480
- name: Dive - check image for waste files
7581
if: steps.changed-files-specific.outputs.any_changed == 'true'
7682
# yamllint disable-line rule:line-length
7783
uses: MaxymVlasov/dive-action@379af3fc636888ada5899c997e8b52db6ad45023 # v1.0.1
7884
with:
79-
image: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
85+
image: ${{ env.IMAGE }}
8086
config-file: ${{ github.workspace }}/.github/.dive-ci.yaml
8187
github-token: ${{ secrets.GITHUB_TOKEN }}
8288

@@ -95,8 +101,7 @@ jobs:
95101
INSTALL_ALL=true
96102
platforms: linux/amd64,linux/arm64
97103
push: false
98-
tags: |
99-
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
104+
tags: ${{ env.IMAGE }}
100105
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
101106
provenance: false
102107
secrets: |

.github/workflows/build-image.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ jobs:
3737
|| echo 'latest'
3838
) >> $GITHUB_ENV
3939
40+
- name: Set IMAGE_REPO environment variable
41+
# Lowercase the repo name for make able to run workflow in forks,
42+
# which owners have uppercase letters in nickname
43+
run: >-
44+
echo "IMAGE_REPO=ghcr.io/${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV
45+
4046
- name: Set up Docker Buildx
4147
# yamllint disable-line rule:line-length
4248
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
@@ -52,8 +58,8 @@ jobs:
5258
platforms: linux/amd64,linux/arm64
5359
push: true
5460
tags: |
55-
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
56-
ghcr.io/${{ github.repository }}:latest
61+
${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}
62+
${{ env.IMAGE_REPO }}:latest
5763
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
5864
provenance: false
5965
secrets: |
@@ -70,7 +76,7 @@ jobs:
7076
platforms: linux/amd64,linux/arm64
7177
push: true
7278
tags: |
73-
ghcr.io/${{ github.repository }}:nightly
79+
${{ env.IMAGE_REPO }}:nightly
7480
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
7581
provenance: false
7682
secrets: |

0 commit comments

Comments
 (0)