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:
214
.github/workflows/build.yml
vendored
214
.github/workflows/build.yml
vendored
@@ -1,27 +1,28 @@
|
|||||||
name: Build and Push Multi-Arch Docker Images
|
name: Multi-Architecture Docker Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
image_name:
|
image_name:
|
||||||
description: 'Docker image name (e.g. user/image)'
|
description: 'Docker image name (e.g., user/image)'
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
tags:
|
image_tag:
|
||||||
description: 'Comma-separated tags (e.g. v1.01,latest,dev,beta)'
|
description: 'Docker image tag (e.g., latest, v1.1.0)'
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
push_dockerhub:
|
default: 'latest'
|
||||||
|
push_to_dockerhub:
|
||||||
description: 'Push to Docker Hub'
|
description: 'Push to Docker Hub'
|
||||||
required: false
|
required: false
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
push_ghcr:
|
push_to_ghcr:
|
||||||
description: 'Push to GitHub Container Registry'
|
description: 'Push to GitHub Container Registry'
|
||||||
required: false
|
required: false
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
push_quay:
|
push_to_quay:
|
||||||
description: 'Push to Quay.io'
|
description: 'Push to Quay.io'
|
||||||
required: false
|
required: false
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -30,100 +31,139 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: ${{ inputs.push_dockerhub == 'true' }}
|
if: ${{ inputs.push_to_dockerhub }}
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: docker.io
|
username: ${{ vars.DOCKERHUB_USERNAME || github.actor }}
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
continue-on-error: true
|
||||||
- name: Log in to GitHub Container Registry
|
id: dockerhub-login
|
||||||
if: ${{ inputs.push_ghcr == 'true' }}
|
|
||||||
uses: docker/login-action@v2
|
- name: Login to GitHub Container Registry
|
||||||
|
if: ${{ inputs.push_to_ghcr }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GHCR_TOKEN }}
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
continue-on-error: true
|
||||||
- name: Log in to Quay.io
|
id: ghcr-login
|
||||||
if: ${{ inputs.push_quay == 'true' }}
|
|
||||||
uses: docker/login-action@v2
|
- name: Login to Quay.io
|
||||||
|
if: ${{ inputs.push_to_quay }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: quay.io
|
registry: quay.io
|
||||||
username: ${{ secrets.QUAY_USERNAME }}
|
username: ${{ secrets.QUAY_USERNAME }}
|
||||||
password: ${{ secrets.QUAY_PASSWORD }}
|
password: ${{ secrets.QUAY_PASSWORD }}
|
||||||
|
continue-on-error: true
|
||||||
- name: Prepare tags
|
id: quay-login
|
||||||
id: prepare_tags
|
|
||||||
|
- name: Extract metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
name=${{ inputs.image_name }},enable=${{ inputs.push_to_dockerhub && steps.dockerhub-login.outcome == 'success' }}
|
||||||
|
name=ghcr.io/${{ inputs.image_name }},enable=${{ inputs.push_to_ghcr && steps.ghcr-login.outcome == 'success' }}
|
||||||
|
name=quay.io/${{ inputs.image_name }},enable=${{ inputs.push_to_quay && steps.quay-login.outcome == 'success' }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=${{ inputs.image_tag }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
continue-on-error: false
|
||||||
|
|
||||||
|
- name: Push to Docker Hub (fallback)
|
||||||
|
if: ${{ inputs.push_to_dockerhub && steps.dockerhub-login.outcome == 'success' && failure() }}
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ inputs.image_name }}:${{ inputs.image_tag }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Push to GHCR (fallback)
|
||||||
|
if: ${{ inputs.push_to_ghcr && steps.ghcr-login.outcome == 'success' && failure() }}
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ghcr.io/${{ inputs.image_name }}:${{ inputs.image_tag }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Push to Quay.io (fallback)
|
||||||
|
if: ${{ inputs.push_to_quay && steps.quay-login.outcome == 'success' && failure() }}
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: quay.io/${{ inputs.image_name }}:${{ inputs.image_tag }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Build Summary
|
||||||
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
echo "IMAGE_NAME=${{ inputs.image_name }}" >> $GITHUB_ENV
|
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
|
||||||
# Normalize tags: remove spaces and split by comma
|
echo "**Image Name:** ${{ inputs.image_name }}" >> $GITHUB_STEP_SUMMARY
|
||||||
TAGS_RAW="${{ inputs.tags }}"
|
echo "**Image Tag:** ${{ inputs.image_tag }}" >> $GITHUB_STEP_SUMMARY
|
||||||
TAGS=$(echo "$TAGS_RAW" | tr -d ' ' | tr ',' '\n')
|
echo "**Platforms:** linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "TAGS=$TAGS_RAW" >> $GITHUB_ENV
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "TAGS_LIST<<EOF" >> $GITHUB_ENV
|
echo "### Registry Push Status:" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "$TAGS" >> $GITHUB_ENV
|
|
||||||
echo "EOF" >> $GITHUB_ENV
|
if [[ "${{ inputs.push_to_dockerhub }}" == "true" ]]; then
|
||||||
|
if [[ "${{ steps.dockerhub-login.outcome }}" == "success" ]]; then
|
||||||
- name: Build & push to Docker Hub
|
echo "- ✅ Docker Hub: Attempted" >> $GITHUB_STEP_SUMMARY
|
||||||
if: ${{ inputs.push_dockerhub == 'true' }}
|
else
|
||||||
run: |
|
echo "- ❌ Docker Hub: Login failed" >> $GITHUB_STEP_SUMMARY
|
||||||
set +e
|
fi
|
||||||
for TAG in $(echo $TAGS | tr '\n' ' '); do
|
else
|
||||||
TAGS_ARGS="$TAGS_ARGS -t docker.io/$IMAGE_NAME:$TAG"
|
echo "- ⏭️ Docker Hub: Skipped" >> $GITHUB_STEP_SUMMARY
|
||||||
done
|
|
||||||
echo "Building and pushing to Docker Hub..."
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/amd64,linux/arm64 \
|
|
||||||
$TAGS_ARGS \
|
|
||||||
--push \
|
|
||||||
.
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Warning: Docker Hub push failed."
|
|
||||||
fi
|
fi
|
||||||
shell: bash
|
|
||||||
|
if [[ "${{ inputs.push_to_ghcr }}" == "true" ]]; then
|
||||||
- name: Build & push to GitHub Container Registry
|
if [[ "${{ steps.ghcr-login.outcome }}" == "success" ]]; then
|
||||||
if: ${{ inputs.push_ghcr == 'true' }}
|
echo "- ✅ GHCR: Attempted" >> $GITHUB_STEP_SUMMARY
|
||||||
run: |
|
else
|
||||||
set +e
|
echo "- ❌ GHCR: Login failed" >> $GITHUB_STEP_SUMMARY
|
||||||
for TAG in $(echo $TAGS | tr '\n' ' '); do
|
fi
|
||||||
TAGS_ARGS="$TAGS_ARGS -t ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$TAG"
|
else
|
||||||
done
|
echo "- ⏭️ GHCR: Skipped" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "Building and pushing to GHCR..."
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/amd64,linux/arm64 \
|
|
||||||
$TAGS_ARGS \
|
|
||||||
--push \
|
|
||||||
.
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Warning: GHCR push failed."
|
|
||||||
fi
|
fi
|
||||||
shell: bash
|
|
||||||
|
if [[ "${{ inputs.push_to_quay }}" == "true" ]]; then
|
||||||
- name: Build & push to Quay.io
|
if [[ "${{ steps.quay-login.outcome }}" == "success" ]]; then
|
||||||
if: ${{ inputs.push_quay == 'true' }}
|
echo "- ✅ Quay.io: Attempted" >> $GITHUB_STEP_SUMMARY
|
||||||
run: |
|
else
|
||||||
set +e
|
echo "- ❌ Quay.io: Login failed" >> $GITHUB_STEP_SUMMARY
|
||||||
for TAG in $(echo $TAGS | tr '\n' ' '); do
|
fi
|
||||||
TAGS_ARGS="$TAGS_ARGS -t quay.io/$IMAGE_NAME:$TAG"
|
else
|
||||||
done
|
echo "- ⏭️ Quay.io: Skipped" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "Building and pushing to Quay.io..."
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/amd64,linux/arm64 \
|
|
||||||
$TAGS_ARGS \
|
|
||||||
--push \
|
|
||||||
.
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Warning: Quay.io push failed."
|
|
||||||
fi
|
fi
|
||||||
shell: bash
|
|
||||||
|
|||||||
Reference in New Issue
Block a user