Skip to content

Commit

Permalink
Lowercase actor name when constructing docker tag names
Browse files Browse the repository at this point in the history
This resolves errors like:

Error: buildx failed with: ERROR: invalid tag "ghcr.io/Stephane-D/sgdk-m68k-gcc:latest": repository name must be lowercase
  • Loading branch information
joeyparrish committed Apr 4, 2024
1 parent be54e33 commit c70ef61
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/sgdk-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,31 @@ jobs:
uses: docker/login-action@v3
with:
registry: ghcr.io
# Here github.actor is used without converting to lowercase, because
# it's the login name, not the package name.
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Compute ghcr org name
# github.actor may be mixed case. While GitHub Actions is
# case-insensitive when comparing strings, GHCR requires a lowercase
# name.
run: |
ACTOR="${{ github.actor }}
# The bash expansion below lowercases the variable, which we then
# write to the GitHub Actions environment for subsequent steps to
# use.
echo "GHCR_ORG=${ACTOR,,}}" >> "$GITHUB_ENV"
- name: Check if GCC Dockerfile has changed
id: changed-files
uses: tj-actions/changed-files@v42
with:
files_yaml: |
gcc:
- deps/gcc.Dockerfile
# If the Dockerfile, sample configs, or this workflow changed,
# rebuild GCC.
- deps/**
- .github/workflows/sgdk-docker.yml
- name: Build m68k GCC (only if changed)
Expand All @@ -71,7 +86,7 @@ jobs:
file: deps/gcc.Dockerfile
context: deps/
platforms: ${{ env.PLATFORMS }}
tags: ghcr.io/${{ github.actor }}/sgdk-m68k-gcc:latest
tags: ghcr.io/${{ env.GHCR_ORG }}/sgdk-m68k-gcc:latest
push: false
load: true

Expand All @@ -80,18 +95,18 @@ jobs:
- name: Push m68k GCC (only if changed, only on push event)
if: steps.changed-files.outputs.gcc_any_changed == 'true' && github.event_name == 'push'
run: |
docker image push ghcr.io/${{ github.actor }}/sgdk-m68k-gcc:latest
docker image push ghcr.io/${{ env.GHCR_ORG }}/sgdk-m68k-gcc:latest
# Right after forking SGDK, the fork will not have a GCC image.
# We may need to fetch the latest from upstream before building SGDK.
- name: Bootstrap m68k GCC
if: steps.changed-files.outputs.gcc_any_changed == 'false'
run: |
# Pull from the user's fork, fall back to the upstream repo.
if ! docker pull ghcr.io/${{ github.actor }}/sgdk-m68k-gcc:latest; then
if ! docker pull ghcr.io/${{ env.GHCR_ORG }}/sgdk-m68k-gcc:latest; then
docker pull ghcr.io/stephane-d/sgdk-m68k-gcc:latest
docker tag ghcr.io/stephane-d/sgdk-m68k-gcc:latest \
ghcr.io/${{ github.actor }}/sgdk-m68k-gcc:latest
ghcr.io/${{ env.GHCR_ORG }}/sgdk-m68k-gcc:latest
# Note that we are not pushing the upstream version to the fork.
# The workflow will update the fork if/when the GCC Dockerfile
# changes in "master", even if those changes come from upstream.
Expand All @@ -104,8 +119,8 @@ jobs:
context: .
platforms: ${{ env.PLATFORMS }}
build-args: |
BASE_IMAGE=ghcr.io/${{ github.actor }}/sgdk-m68k-gcc
tags: ghcr.io/${{ github.actor }}/sgdk:latest
BASE_IMAGE=ghcr.io/${{ env.GHCR_ORG }}/sgdk-m68k-gcc
tags: ghcr.io/${{ env.GHCR_ORG }}/sgdk:latest
push: false
load: true

Expand All @@ -114,4 +129,4 @@ jobs:
- name: Push SGDK (only on push event)
if: github.event_name == 'push'
run: |
docker image push ghcr.io/${{ github.actor }}/sgdk:latest
docker image push ghcr.io/${{ env.GHCR_ORG }}/sgdk:latest

0 comments on commit c70ef61

Please sign in to comment.