Skip to content

Commit

Permalink
Sanitize the registry image name
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroCC committed Oct 18, 2024
1 parent 17b9259 commit a09d434
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,37 @@ on:
push:

env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
# Only push images on forks or the main branch
PUSH_IMAGE: ${{ (github.ref_name == 'master') || (github.repository_owner != 'moos-ivp') }}

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
commit_time: ${{ steps.prepare.outputs.commit_time }}
commit_time: ${{ steps.prepare.outputs.COMMIT_TIMESTAMP }}
registry_image: ${{ steps.prepare.outputs.REGISTRY_IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Prepare commit timestamp
- name: Prepare various metadata
id: prepare
run: |
# Get the commit timestamp
export "COMMIT_TIMESTAMP=$(git log -1 --pretty=%ct)"
echo "COMMIT_TIMESTAMP = $COMMIT_TIMESTAMP"
echo $COMMIT_TIMESTAMP >> $GITHUB_OUTPUT
echo "COMMIT_TIMESTAMP=$COMMIT_TIMESTAMP" | tee $GITHUB_OUTPUT
# Lowercase the repository name
UNSANITIZED_REGISTRY_IMAGE=ghcr.io/${{ github.repository }}
echo "REGISTRY_IMAGE=${UNSANITIZED_REGISTRY_IMAGE,,}" | tee $GITHUB_OUTPUT
build-minrobot:
runs-on: ubuntu-latest
needs:
- prepare
env:
SOURCE_DATE_EPOCH: ${{ needs.prepare.outputs.commit_time }}
REGISTRY_IMAGE: ${{ needs.prepare.outputs.registry_image }}
outputs:
# So we can `FROM` this image in the next build
digest: ${{ steps.build.outputs.digest }}
Expand Down Expand Up @@ -76,11 +84,13 @@ jobs:

build-gui:
runs-on: ubuntu-latest
needs:
needs:
- prepare
- build-minrobot
env:
FLAVOR: "-gui"
SOURCE_DATE_EPOCH: ${{ needs.prepare.outputs.commit_time }}
REGISTRY_IMAGE: ${{ needs.prepare.outputs.registry_image }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down

0 comments on commit a09d434

Please sign in to comment.