mirror of
https://github.com/driftywinds/twitchrise-bot.git
synced 2025-12-19 11:43:33 +00:00
Update build.yml
This commit is contained in:
61
.github/workflows/build.yml
vendored
61
.github/workflows/build.yml
vendored
@@ -39,18 +39,18 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Parse tags
|
- name: Normalize tags
|
||||||
id: tags
|
id: vars
|
||||||
run: |
|
run: |
|
||||||
TAGS_INPUT="${{ github.event.inputs.tags }}"
|
TAGS_INPUT="${{ github.event.inputs.tags }}"
|
||||||
IFS=',' read -ra TAGS_ARRAY <<< "$TAGS_INPUT"
|
IFS=',' read -ra TAGS_ARRAY <<< "$TAGS_INPUT"
|
||||||
for i in "${TAGS_ARRAY[@]}"; do
|
CLEAN_TAGS=()
|
||||||
CLEAN_TAG="$(echo "$i" | xargs)" # trim spaces
|
for t in "${TAGS_ARRAY[@]}"; do
|
||||||
echo "tag=$CLEAN_TAG" >> "$GITHUB_OUTPUT"
|
CLEAN_TAGS+=("$(echo "$t" | xargs)")
|
||||||
echo "tags_list=${tags_list} $CLEAN_TAG" >> "$GITHUB_OUTPUT"
|
|
||||||
done
|
done
|
||||||
|
echo "tags_list=${CLEAN_TAGS[*]}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# Docker Hub login (optional)
|
# Login (optional per registry)
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: ${{ github.event.inputs.push_dockerhub == 'true' }}
|
if: ${{ github.event.inputs.push_dockerhub == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@@ -58,7 +58,6 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
# GHCR login (optional)
|
|
||||||
- name: Login to GHCR
|
- name: Login to GHCR
|
||||||
if: ${{ github.event.inputs.push_ghcr == 'true' }}
|
if: ${{ github.event.inputs.push_ghcr == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@@ -67,7 +66,6 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GHCR_TOKEN }}
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
|
||||||
# Quay.io login (optional)
|
|
||||||
- name: Login to Quay.io
|
- name: Login to Quay.io
|
||||||
if: ${{ github.event.inputs.push_quay == 'true' }}
|
if: ${{ github.event.inputs.push_quay == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@@ -76,42 +74,45 @@ jobs:
|
|||||||
username: ${{ secrets.QUAY_USERNAME }}
|
username: ${{ secrets.QUAY_USERNAME }}
|
||||||
password: ${{ secrets.QUAY_TOKEN }}
|
password: ${{ secrets.QUAY_TOKEN }}
|
||||||
|
|
||||||
# Push to Docker Hub
|
# Build once and store in local cache
|
||||||
- name: Build & Push to Docker Hub
|
- name: Build multi-arch image
|
||||||
if: ${{ github.event.inputs.push_dockerhub == 'true' }}
|
|
||||||
run: |
|
run: |
|
||||||
set -e
|
|
||||||
for tag in $(echo "${{ github.event.inputs.tags }}" | tr ',' ' '); do
|
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64,linux/arm64 \
|
--platform linux/amd64,linux/arm64 \
|
||||||
--push \
|
--output=type=registry,dest=/tmp/buildcache.tar \
|
||||||
-t docker.io/${{ secrets.DOCKERHUB_USERNAME }}/$(basename $GITHUB_REPOSITORY):$(echo "$tag" | xargs) .
|
-t tempimage:build .
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
# Push to Docker Hub
|
||||||
|
- name: Push to Docker Hub
|
||||||
|
if: ${{ github.event.inputs.push_dockerhub == 'true' }}
|
||||||
|
run: |
|
||||||
|
docker load < /tmp/buildcache.tar || true
|
||||||
|
for tag in ${{ steps.vars.outputs.tags_list }}; do
|
||||||
|
docker tag tempimage:build docker.io/${{ secrets.DOCKERHUB_USERNAME }}/$(basename $GITHUB_REPOSITORY):$tag
|
||||||
|
docker push docker.io/${{ secrets.DOCKERHUB_USERNAME }}/$(basename $GITHUB_REPOSITORY):$tag || echo "Docker Hub push failed for tag $tag"
|
||||||
done
|
done
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
# Push to GHCR
|
# Push to GHCR
|
||||||
- name: Build & Push to GHCR
|
- name: Push to GHCR
|
||||||
if: ${{ github.event.inputs.push_ghcr == 'true' }}
|
if: ${{ github.event.inputs.push_ghcr == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
docker load < /tmp/buildcache.tar || true
|
||||||
REPO_NAME=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
|
REPO_NAME=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
|
||||||
for tag in $(echo "${{ github.event.inputs.tags }}" | tr ',' ' '); do
|
for tag in ${{ steps.vars.outputs.tags_list }}; do
|
||||||
docker buildx build \
|
docker tag tempimage:build ghcr.io/$REPO_NAME:$tag
|
||||||
--platform linux/amd64,linux/arm64 \
|
docker push ghcr.io/$REPO_NAME:$tag || echo "GHCR push failed for tag $tag"
|
||||||
--push \
|
|
||||||
-t ghcr.io/${REPO_NAME}:$(echo "$tag" | xargs) .
|
|
||||||
done
|
done
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
# Push to Quay.io
|
# Push to Quay.io
|
||||||
- name: Build & Push to Quay.io
|
- name: Push to Quay.io
|
||||||
if: ${{ github.event.inputs.push_quay == 'true' }}
|
if: ${{ github.event.inputs.push_quay == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
docker load < /tmp/buildcache.tar || true
|
||||||
for tag in $(echo "${{ github.event.inputs.tags }}" | tr ',' ' '); do
|
for tag in ${{ steps.vars.outputs.tags_list }}; do
|
||||||
docker buildx build \
|
docker tag tempimage:build quay.io/${{ secrets.QUAY_USERNAME }}/$(basename $GITHUB_REPOSITORY):$tag
|
||||||
--platform linux/amd64,linux/arm64 \
|
docker push quay.io/${{ secrets.QUAY_USERNAME }}/$(basename $GITHUB_REPOSITORY):$tag || echo "Quay push failed for tag $tag"
|
||||||
--push \
|
|
||||||
-t quay.io/${{ secrets.QUAY_USERNAME }}/$(basename $GITHUB_REPOSITORY):$(echo "$tag" | xargs) .
|
|
||||||
done
|
done
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|||||||
Reference in New Issue
Block a user