mirror of
https://github.com/driftywinds/twitchrise-bot.git
synced 2025-12-19 03:33:32 +00:00
Update build.yml
This commit is contained in:
49
.github/workflows/build.yml
vendored
49
.github/workflows/build.yml
vendored
@@ -4,26 +4,24 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
image_name:
|
||||
description: "Base image name (e.g. myuser/myimage or repo/image)."
|
||||
description: "Base image name (e.g. myuser/myimage or repo/image)"
|
||||
required: true
|
||||
tags:
|
||||
description: "Image tags (comma or space separated). Example: v1.01 latest beta"
|
||||
required: true
|
||||
dockerhub_user:
|
||||
description: "Docker Hub username (leave empty if not pushing to Docker Hub)"
|
||||
description: "Docker Hub username (if pushing there)"
|
||||
required: false
|
||||
push_to_dockerhub:
|
||||
description: "Push to Docker Hub? (true/false)"
|
||||
registries_to_push:
|
||||
type: choice
|
||||
description: "Select registries to push to"
|
||||
options:
|
||||
- dockerhub
|
||||
- ghcr
|
||||
- quay
|
||||
required: false
|
||||
default: "false"
|
||||
push_to_ghcr:
|
||||
description: "Push to GHCR? (true/false)"
|
||||
required: false
|
||||
default: "false"
|
||||
push_to_quay:
|
||||
description: "Push to Quay.io? (true/false)"
|
||||
required: false
|
||||
default: "false"
|
||||
default: []
|
||||
multiple: true # allows checkbox-like UI
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
@@ -44,22 +42,17 @@ jobs:
|
||||
TAGS_INPUT: ${{ github.event.inputs.tags }}
|
||||
IMAGE_NAME: ${{ github.event.inputs.image_name }}
|
||||
DOCKERHUB_USER: ${{ github.event.inputs.dockerhub_user }}
|
||||
PUSH_DOCKERHUB: ${{ github.event.inputs.push_to_dockerhub }}
|
||||
PUSH_GHCR: ${{ github.event.inputs.push_to_ghcr }}
|
||||
PUSH_QUAY: ${{ github.event.inputs.push_to_quay }}
|
||||
REGISTRIES: ${{ github.event.inputs.registries_to_push }}
|
||||
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
# normalize commas to spaces
|
||||
TAGS_INPUT=$(echo "${TAGS_INPUT:-}" | tr ',' ' ')
|
||||
|
||||
TAG_ARGS=""
|
||||
PRINT_LIST=""
|
||||
|
||||
for TAG in $TAGS_INPUT; do
|
||||
# Docker Hub
|
||||
if [ "${PUSH_DOCKERHUB}" = "true" ]; then
|
||||
if [[ "${REGISTRIES}" == *"dockerhub"* ]]; then
|
||||
if [ -n "${DOCKERHUB_USER}" ]; then
|
||||
FULL_TAG="docker.io/${DOCKERHUB_USER}/${IMAGE_NAME}:$TAG"
|
||||
else
|
||||
@@ -69,23 +62,19 @@ jobs:
|
||||
PRINT_LIST="${PRINT_LIST}${FULL_TAG} "
|
||||
fi
|
||||
|
||||
# GHCR (use repo owner namespace)
|
||||
if [ "${PUSH_GHCR}" = "true" ]; then
|
||||
if [[ "${REGISTRIES}" == *"ghcr"* ]]; then
|
||||
FULL_TAG="ghcr.io/${GITHUB_REPOSITORY_OWNER}/${IMAGE_NAME}:$TAG"
|
||||
TAG_ARGS="${TAG_ARGS} --tag ${FULL_TAG}"
|
||||
PRINT_LIST="${PRINT_LIST}${FULL_TAG} "
|
||||
fi
|
||||
|
||||
# Quay
|
||||
if [ "${PUSH_QUAY}" = "true" ]; then
|
||||
# If you want an org prefix for quay, include it in IMAGE_NAME when running the workflow
|
||||
if [[ "${REGISTRIES}" == *"quay"* ]]; then
|
||||
FULL_TAG="quay.io/${IMAGE_NAME}:$TAG"
|
||||
TAG_ARGS="${TAG_ARGS} --tag ${FULL_TAG}"
|
||||
PRINT_LIST="${PRINT_LIST}${FULL_TAG} "
|
||||
fi
|
||||
done
|
||||
|
||||
# Export outputs for later steps
|
||||
echo "tags=${TAG_ARGS}" >> "$GITHUB_OUTPUT"
|
||||
echo "computed_tags=${PRINT_LIST}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -104,18 +93,18 @@ jobs:
|
||||
- name: Fail early if no tags computed
|
||||
if: ${{ steps.tagger.outputs.computed_tags == '' }}
|
||||
run: |
|
||||
echo "ERROR: No tags were computed for any registry. Check inputs (image_name, tags, and push_to_* flags)." >&2
|
||||
echo "ERROR: No tags were computed for any registry. Check inputs." >&2
|
||||
exit 1
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
if: github.event.inputs.push_to_dockerhub == 'true'
|
||||
if: contains(github.event.inputs.registries_to_push, 'dockerhub')
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ github.event.inputs.dockerhub_user }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Log in to GHCR
|
||||
if: github.event.inputs.push_to_ghcr == 'true'
|
||||
if: contains(github.event.inputs.registries_to_push, 'ghcr')
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
@@ -123,7 +112,7 @@ jobs:
|
||||
password: ${{ secrets.GHCR_TOKEN }}
|
||||
|
||||
- name: Log in to Quay.io
|
||||
if: github.event.inputs.push_to_quay == 'true'
|
||||
if: contains(github.event.inputs.registries_to_push, 'quay')
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: quay.io
|
||||
|
||||
Reference in New Issue
Block a user