Refactor Docker image workflow for registry handling
Removed registry input and adjusted Docker Hub login condition.
This commit is contained in:
41
.github/workflows/docker-image.yml
vendored
41
.github/workflows/docker-image.yml
vendored
@@ -11,15 +11,6 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
default: false
|
default: false
|
||||||
type: boolean
|
type: boolean
|
||||||
registry:
|
|
||||||
description: "Docker registry to push to"
|
|
||||||
required: true
|
|
||||||
default: "both"
|
|
||||||
type: choice
|
|
||||||
options:
|
|
||||||
- "ghcr"
|
|
||||||
- "dockerhub"
|
|
||||||
- "both"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -43,42 +34,38 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
VERSION=${{ github.event.inputs.version }}
|
VERSION=${{ github.event.inputs.version }}
|
||||||
PROD=${{ github.event.inputs.production }}
|
PROD=${{ github.event.inputs.production }}
|
||||||
REGISTRY=${{ github.event.inputs.registry }}
|
|
||||||
|
|
||||||
TAGS=()
|
TAGS=()
|
||||||
if [ "$PROD" = "true" ]; then
|
|
||||||
TAGS+=("release-$VERSION")
|
|
||||||
TAGS+=("latest")
|
|
||||||
else
|
|
||||||
TAGS+=("dev-$VERSION")
|
|
||||||
fi
|
|
||||||
|
|
||||||
ALL_TAGS=()
|
ALL_TAGS=()
|
||||||
for tag in "${TAGS[@]}"; do
|
|
||||||
if [ "$REGISTRY" = "ghcr" ] || [ "$REGISTRY" = "both" ]; then
|
|
||||||
ALL_TAGS+=("ghcr.io/lukegus/termix:$tag")
|
|
||||||
fi
|
|
||||||
if [ "$REGISTRY" = "dockerhub" ] || [ "$REGISTRY" = "both" ]; then
|
|
||||||
if [ "$PROD" = "true" ]; then
|
if [ "$PROD" = "true" ]; then
|
||||||
|
# Production build → push release + latest to both GHCR and Docker Hub
|
||||||
|
TAGS+=("release-$VERSION" "latest")
|
||||||
|
for tag in "${TAGS[@]}"; do
|
||||||
|
ALL_TAGS+=("ghcr.io/lukegus/termix:$tag")
|
||||||
ALL_TAGS+=("docker.io/bugattiguy527/termix:$tag")
|
ALL_TAGS+=("docker.io/bugattiguy527/termix:$tag")
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
# Dev build → push only dev-x.x.x to GHCR
|
||||||
|
TAGS+=("dev-$VERSION")
|
||||||
|
for tag in "${TAGS[@]}"; do
|
||||||
|
ALL_TAGS+=("ghcr.io/lukegus/termix:$tag")
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
echo "ALL_TAGS=${ALL_TAGS[*]}" >> $GITHUB_ENV
|
echo "ALL_TAGS=${ALL_TAGS[*]}" >> $GITHUB_ENV
|
||||||
echo "All tags to build:"
|
echo "All tags to build:"
|
||||||
printf '%s\n' "${ALL_TAGS[@]}"
|
printf '%s\n' "${ALL_TAGS[@]}"
|
||||||
|
|
||||||
- name: Login to GHCR
|
- name: Login to GHCR
|
||||||
if: ${{ github.event.inputs.registry == 'ghcr' || github.event.inputs.registry == 'both' }}
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: lukegus
|
username: lukegus
|
||||||
password: ${{ secrets.GHCR_TOKEN }}
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub (prod only)
|
||||||
if: ${{ github.event.inputs.registry == 'dockerhub' || github.event.inputs.registry == 'both' }}
|
if: ${{ github.event.inputs.production == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: bugattiguy527
|
username: bugattiguy527
|
||||||
|
|||||||
Reference in New Issue
Block a user