fix: use hardcoded image names in build workflow
Replaces dynamic image name determination with hardcoded values: - GHCR: ghcr.io/lfnovo/open-notebook - Docker Hub: lfnovo/open_notebook This fixes the issue where dynamic name parsing was creating empty image names, resulting in invalid Docker tags like ":1.0.0-single". Changes: - Remove complex repository name parsing logic - Hardcode image names in workflow env section - Add tag preparation steps that build comma-separated tag lists - Properly handle empty push_latest input for release events Related to PR #163
This commit is contained in:
parent
a51bb9d792
commit
21181aa0be
1 changed files with 70 additions and 42 deletions
112
.github/workflows/build-and-release.yml
vendored
112
.github/workflows/build-and-release.yml
vendored
|
|
@ -25,17 +25,14 @@ permissions:
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Dynamic registry and image configuration based on repository
|
GHCR_IMAGE: ghcr.io/lfnovo/open-notebook
|
||||||
GHCR_REGISTRY: ghcr.io
|
DOCKERHUB_IMAGE: lfnovo/open_notebook
|
||||||
DOCKER_HUB_REGISTRY: docker.io
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
extract-version:
|
extract-version:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.version.outputs.version }}
|
version: ${{ steps.version.outputs.version }}
|
||||||
ghcr_image: ${{ steps.image.outputs.ghcr_image }}
|
|
||||||
dockerhub_image: ${{ steps.image.outputs.dockerhub_image }}
|
|
||||||
has_dockerhub_secrets: ${{ steps.check.outputs.has_dockerhub_secrets }}
|
has_dockerhub_secrets: ${{ steps.check.outputs.has_dockerhub_secrets }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|
@ -48,23 +45,6 @@ jobs:
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "Extracted version: $VERSION"
|
echo "Extracted version: $VERSION"
|
||||||
|
|
||||||
- name: Determine image names
|
|
||||||
id: image
|
|
||||||
run: |
|
|
||||||
# Extract owner and repo name from GITHUB_REPOSITORY (format: owner/repo)
|
|
||||||
REPO_OWNER=$(echo "${{ github.repository }}" | cut -d'/' -f1)
|
|
||||||
REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2)
|
|
||||||
|
|
||||||
# GHCR image: ghcr.io/owner/repo
|
|
||||||
GHCR_IMAGE="${{ env.GHCR_REGISTRY }}/${REPO_OWNER}/${REPO_NAME}"
|
|
||||||
echo "ghcr_image=${GHCR_IMAGE}" >> $GITHUB_OUTPUT
|
|
||||||
echo "GHCR Image: ${GHCR_IMAGE}"
|
|
||||||
|
|
||||||
# Docker Hub image: owner/repo (use lowercase for Docker Hub compatibility)
|
|
||||||
DOCKERHUB_IMAGE="${REPO_OWNER}/${REPO_NAME}"
|
|
||||||
echo "dockerhub_image=${DOCKERHUB_IMAGE}" >> $GITHUB_OUTPUT
|
|
||||||
echo "Docker Hub Image: ${DOCKERHUB_IMAGE}"
|
|
||||||
|
|
||||||
- name: Check for Docker Hub credentials
|
- name: Check for Docker Hub credentials
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -109,6 +89,34 @@ jobs:
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-buildx-regular-
|
${{ runner.os }}-buildx-regular-
|
||||||
|
|
||||||
|
- name: Prepare Docker tags for regular build
|
||||||
|
id: tags-regular
|
||||||
|
run: |
|
||||||
|
TAGS="${{ env.GHCR_IMAGE }}:${{ needs.extract-version.outputs.version }}"
|
||||||
|
|
||||||
|
# Determine if we should push latest tags
|
||||||
|
PUSH_LATEST="${{ github.event.inputs.push_latest }}"
|
||||||
|
if [[ -z "$PUSH_LATEST" ]]; then
|
||||||
|
PUSH_LATEST="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add GHCR latest tag if requested or for non-prerelease releases
|
||||||
|
if [[ "$PUSH_LATEST" == "true" ]] || [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" != "true" ]]; then
|
||||||
|
TAGS="${TAGS},${{ env.GHCR_IMAGE }}:v1-latest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add Docker Hub tags if credentials available
|
||||||
|
if [[ "${{ needs.extract-version.outputs.has_dockerhub_secrets }}" == "true" ]]; then
|
||||||
|
TAGS="${TAGS},${{ env.DOCKERHUB_IMAGE }}:${{ needs.extract-version.outputs.version }}"
|
||||||
|
|
||||||
|
if [[ "$PUSH_LATEST" == "true" ]] || [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" != "true" ]]; then
|
||||||
|
TAGS="${TAGS},${{ env.DOCKERHUB_IMAGE }}:v1-latest"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
|
||||||
|
echo "Generated tags: ${TAGS}"
|
||||||
|
|
||||||
- name: Build and push regular image
|
- name: Build and push regular image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
|
|
@ -116,11 +124,7 @@ jobs:
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: ${{ steps.tags-regular.outputs.tags }}
|
||||||
${{ needs.extract-version.outputs.ghcr_image }}:${{ needs.extract-version.outputs.version }}
|
|
||||||
${{ (github.event.inputs.push_latest == 'true' || (github.event_name == 'release' && !github.event.release.prerelease)) && format('{0}:v1-latest', needs.extract-version.outputs.ghcr_image) || '' }}
|
|
||||||
${{ needs.extract-version.outputs.has_dockerhub_secrets == 'true' && format('{0}:{1}', needs.extract-version.outputs.dockerhub_image, needs.extract-version.outputs.version) || '' }}
|
|
||||||
${{ (needs.extract-version.outputs.has_dockerhub_secrets == 'true' && (github.event.inputs.push_latest == 'true' || (github.event_name == 'release' && !github.event.release.prerelease))) && format('{0}:v1-latest', needs.extract-version.outputs.dockerhub_image) || '' }}
|
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||||
|
|
||||||
|
|
@ -162,6 +166,34 @@ jobs:
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-buildx-single-
|
${{ runner.os }}-buildx-single-
|
||||||
|
|
||||||
|
- name: Prepare Docker tags for single build
|
||||||
|
id: tags-single
|
||||||
|
run: |
|
||||||
|
TAGS="${{ env.GHCR_IMAGE }}:${{ needs.extract-version.outputs.version }}-single"
|
||||||
|
|
||||||
|
# Determine if we should push latest tags
|
||||||
|
PUSH_LATEST="${{ github.event.inputs.push_latest }}"
|
||||||
|
if [[ -z "$PUSH_LATEST" ]]; then
|
||||||
|
PUSH_LATEST="false"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add GHCR latest tag if requested or for non-prerelease releases
|
||||||
|
if [[ "$PUSH_LATEST" == "true" ]] || [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" != "true" ]]; then
|
||||||
|
TAGS="${TAGS},${{ env.GHCR_IMAGE }}:v1-latest-single"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add Docker Hub tags if credentials available
|
||||||
|
if [[ "${{ needs.extract-version.outputs.has_dockerhub_secrets }}" == "true" ]]; then
|
||||||
|
TAGS="${TAGS},${{ env.DOCKERHUB_IMAGE }}:${{ needs.extract-version.outputs.version }}-single"
|
||||||
|
|
||||||
|
if [[ "$PUSH_LATEST" == "true" ]] || [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" != "true" ]]; then
|
||||||
|
TAGS="${TAGS},${{ env.DOCKERHUB_IMAGE }}:v1-latest-single"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
|
||||||
|
echo "Generated tags: ${TAGS}"
|
||||||
|
|
||||||
- name: Build and push single-container image
|
- name: Build and push single-container image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
|
|
@ -169,11 +201,7 @@ jobs:
|
||||||
file: ./Dockerfile.single
|
file: ./Dockerfile.single
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: ${{ steps.tags-single.outputs.tags }}
|
||||||
${{ needs.extract-version.outputs.ghcr_image }}:${{ needs.extract-version.outputs.version }}-single
|
|
||||||
${{ (github.event.inputs.push_latest == 'true' || (github.event_name == 'release' && !github.event.release.prerelease)) && format('{0}:v1-latest-single', needs.extract-version.outputs.ghcr_image) || '' }}
|
|
||||||
${{ needs.extract-version.outputs.has_dockerhub_secrets == 'true' && format('{0}:{1}-single', needs.extract-version.outputs.dockerhub_image, needs.extract-version.outputs.version) || '' }}
|
|
||||||
${{ (needs.extract-version.outputs.has_dockerhub_secrets == 'true' && (github.event.inputs.push_latest == 'true' || (github.event_name == 'release' && !github.event.release.prerelease))) && format('{0}:v1-latest-single', needs.extract-version.outputs.dockerhub_image) || '' }}
|
|
||||||
cache-from: type=local,src=/tmp/.buildx-cache-single
|
cache-from: type=local,src=/tmp/.buildx-cache-single
|
||||||
cache-to: type=local,dest=/tmp/.buildx-cache-single-new,mode=max
|
cache-to: type=local,dest=/tmp/.buildx-cache-single-new,mode=max
|
||||||
|
|
||||||
|
|
@ -195,9 +223,9 @@ jobs:
|
||||||
echo "**Push Latest:** ${{ github.event.inputs.push_latest || 'true' }}" >> $GITHUB_STEP_SUMMARY
|
echo "**Push Latest:** ${{ github.event.inputs.push_latest || 'true' }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "### Registries:" >> $GITHUB_STEP_SUMMARY
|
echo "### Registries:" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "✅ **GHCR:** \`${{ needs.extract-version.outputs.ghcr_image }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **GHCR:** \`${{ env.GHCR_IMAGE }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
if [[ "${{ needs.extract-version.outputs.has_dockerhub_secrets }}" == "true" ]]; then
|
if [[ "${{ needs.extract-version.outputs.has_dockerhub_secrets }}" == "true" ]]; then
|
||||||
echo "✅ **Docker Hub:** \`${{ needs.extract-version.outputs.dockerhub_image }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **Docker Hub:** \`${{ env.DOCKERHUB_IMAGE }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
else
|
else
|
||||||
echo "⏭️ **Docker Hub:** Skipped (credentials not configured)" >> $GITHUB_STEP_SUMMARY
|
echo "⏭️ **Docker Hub:** Skipped (credentials not configured)" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
@ -205,14 +233,14 @@ jobs:
|
||||||
echo "### Images Built:" >> $GITHUB_STEP_SUMMARY
|
echo "### Images Built:" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
if [[ "${{ needs.build-regular.result }}" == "success" ]]; then
|
if [[ "${{ needs.build-regular.result }}" == "success" ]]; then
|
||||||
echo "✅ **Regular (GHCR):** \`${{ needs.extract-version.outputs.ghcr_image }}:${{ needs.extract-version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **Regular (GHCR):** \`${{ env.GHCR_IMAGE }}:${{ needs.extract-version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
if [[ "${{ github.event.inputs.push_latest }}" == "true" ]]; then
|
if [[ "${{ github.event.inputs.push_latest }}" == "true" ]]; then
|
||||||
echo "✅ **Regular v1-Latest (GHCR):** \`${{ needs.extract-version.outputs.ghcr_image }}:v1-latest\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **Regular v1-Latest (GHCR):** \`${{ env.GHCR_IMAGE }}:v1-latest\`" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
if [[ "${{ needs.extract-version.outputs.has_dockerhub_secrets }}" == "true" ]]; then
|
if [[ "${{ needs.extract-version.outputs.has_dockerhub_secrets }}" == "true" ]]; then
|
||||||
echo "✅ **Regular (Docker Hub):** \`${{ needs.extract-version.outputs.dockerhub_image }}:${{ needs.extract-version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **Regular (Docker Hub):** \`${{ env.DOCKERHUB_IMAGE }}:${{ needs.extract-version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
if [[ "${{ github.event.inputs.push_latest }}" == "true" ]]; then
|
if [[ "${{ github.event.inputs.push_latest }}" == "true" ]]; then
|
||||||
echo "✅ **Regular v1-Latest (Docker Hub):** \`${{ needs.extract-version.outputs.dockerhub_image }}:v1-latest\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **Regular v1-Latest (Docker Hub):** \`${{ env.DOCKERHUB_IMAGE }}:v1-latest\`" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [[ "${{ needs.build-regular.result }}" == "skipped" ]]; then
|
elif [[ "${{ needs.build-regular.result }}" == "skipped" ]]; then
|
||||||
|
|
@ -222,14 +250,14 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${{ needs.build-single.result }}" == "success" ]]; then
|
if [[ "${{ needs.build-single.result }}" == "success" ]]; then
|
||||||
echo "✅ **Single (GHCR):** \`${{ needs.extract-version.outputs.ghcr_image }}:${{ needs.extract-version.outputs.version }}-single\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **Single (GHCR):** \`${{ env.GHCR_IMAGE }}:${{ needs.extract-version.outputs.version }}-single\`" >> $GITHUB_STEP_SUMMARY
|
||||||
if [[ "${{ github.event.inputs.push_latest }}" == "true" ]]; then
|
if [[ "${{ github.event.inputs.push_latest }}" == "true" ]]; then
|
||||||
echo "✅ **Single v1-Latest (GHCR):** \`${{ needs.extract-version.outputs.ghcr_image }}:v1-latest-single\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **Single v1-Latest (GHCR):** \`${{ env.GHCR_IMAGE }}:v1-latest-single\`" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
if [[ "${{ needs.extract-version.outputs.has_dockerhub_secrets }}" == "true" ]]; then
|
if [[ "${{ needs.extract-version.outputs.has_dockerhub_secrets }}" == "true" ]]; then
|
||||||
echo "✅ **Single (Docker Hub):** \`${{ needs.extract-version.outputs.dockerhub_image }}:${{ needs.extract-version.outputs.version }}-single\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **Single (Docker Hub):** \`${{ env.DOCKERHUB_IMAGE }}:${{ needs.extract-version.outputs.version }}-single\`" >> $GITHUB_STEP_SUMMARY
|
||||||
if [[ "${{ github.event.inputs.push_latest }}" == "true" ]]; then
|
if [[ "${{ github.event.inputs.push_latest }}" == "true" ]]; then
|
||||||
echo "✅ **Single v1-Latest (Docker Hub):** \`${{ needs.extract-version.outputs.dockerhub_image }}:v1-latest-single\`" >> $GITHUB_STEP_SUMMARY
|
echo "✅ **Single v1-Latest (Docker Hub):** \`${{ env.DOCKERHUB_IMAGE }}:v1-latest-single\`" >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [[ "${{ needs.build-single.result }}" == "skipped" ]]; then
|
elif [[ "${{ needs.build-single.result }}" == "skipped" ]]; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue