Skip to content

Commit

Permalink
💚 Fix docker build push (#424)
Browse files Browse the repository at this point in the history
* 💚 Fix docker build push

* debug: test push

* try proper login and push

* oof

* Revert "debug: test push"

This reverts commit efceede.
  • Loading branch information
aaronleopold authored Aug 30, 2024
1 parent 03ff5e0 commit bef46c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
26 changes: 17 additions & 9 deletions .github/actions/build-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ runs:
echo "TAGS=$(echo ${{ inputs.tags }} | sed -e 's/,/,aaronleopold\/stump:/g' | sed -e 's/^/aaronleopold\/stump:/')" >> $GITHUB_ENV
shell: bash

- name: Sanity check
run: |
echo "TAGS=${{ env.TAGS }}"
echo "GIT_REV=${{ env.GIT_REV }}"
shell: bash

- name: Setup rust
uses: ./.github/actions/setup-rust
with:
Expand Down Expand Up @@ -63,14 +69,6 @@ runs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
# if both inputs are empty, we assume we're running on a fork and don't need to login
if: ${{ inputs.username != '' && inputs.password != '' }}
with:
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- name: Install podman
if: runner.environment != 'self-hosted'
run: |
Expand All @@ -80,9 +78,19 @@ runs:

- name: Run podman buildx
run: |
ENGINE=podman PLATFORMS="${{ inputs.platforms }}" TAGS="${{ env.TAGS }}" GIT_REV="${{ env.GIT_REV }}" ./docker/build.sh
ENGINE=podman PLATFORMS="${{ inputs.platforms }}" TAGS="${{ env.TAGS }}" GIT_REV="${{ env.GIT_REV }}" PUSH="${{ inputs.push }}" ./docker/build.sh
shell: bash

- name: Push to registry
if: ${{ success() && inputs.push == 'true' }}
uses: redhat-actions/push-to-registry@v2
with:
image: aaronleopold/stump
tags: ${{ env.TAGS }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
registry: docker.io

- name: Discord notification
if: ${{ success() && inputs.push == 'true' && inputs.discord-webhook != '' }}
env:
Expand Down
9 changes: 8 additions & 1 deletion docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ _PLATFORMS=${PLATFORMS:-linux/amd64}
_TAGS=${TAGS:-"aaronleopold/stump:nightly"}
_RUN_PRISMA_GENERATE=${RUN_PRISMA_GENERATE:=false}
_GIT_REV=${GIT_REV:-$(git rev-parse --short HEAD)}
_PUSH=${PUSH:-false}

FORMATTED_TAGS=""
for tag in ${_TAGS//,/}; do
FORMATTED_TAGS="$FORMATTED_TAGS --tag $tag"
done

PUSH_OR_LOAD_ARG="--load"
# Not supported? https://github.com/containers/buildah/issues/4671
# if [ "$_PUSH" = true ]; then
# PUSH_OR_LOAD_ARG="--output=type=registry"
# fi

echo "Building with tag arguments: $FORMATTED_TAGS"

set -ex; \
${_ENGINE} buildx build \
-f ./docker/Dockerfile \
--load \
${PUSH_OR_LOAD_ARG} \
--progress=$_FORMAT \
--platform=$_PLATFORMS \
${FORMATTED_TAGS} \
Expand Down

0 comments on commit bef46c8

Please sign in to comment.