v1.8.0 #429
52
.github/workflows/docker-image.yml
vendored
52
.github/workflows/docker-image.yml
vendored
@@ -1,20 +1,22 @@
|
|||||||
name: Build and Push Docker Image
|
name: Build and Push Multi-Registry Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag_name:
|
tag_name:
|
||||||
description: "Custom tag name for the Docker image"
|
description: "Custom tag name for the Docker image (comma-separated for multiple tags, e.g. latest,release-1.8.0)"
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
registry:
|
push_to_ghcr:
|
||||||
description: "Docker registry to push to"
|
description: "Push to GitHub Container Registry"
|
||||||
|
type: boolean
|
||||||
required: true
|
required: true
|
||||||
default: "ghcr"
|
default: true
|
||||||
type: choice
|
push_to_dockerhub:
|
||||||
options:
|
description: "Push to Docker Hub"
|
||||||
- "ghcr"
|
type: boolean
|
||||||
- "dockerhub"
|
required: true
|
||||||
|
default: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -28,7 +30,7 @@ jobs:
|
|||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: arm64
|
platforms: arm64,arm/v7,arm/v6
|
||||||
|
|
||||||
- name: Setup Blacksmith Builder
|
- name: Setup Blacksmith Builder
|
||||||
uses: useblacksmith/setup-docker-builder@v1
|
uses: useblacksmith/setup-docker-builder@v1
|
||||||
@@ -54,7 +56,7 @@ jobs:
|
|||||||
${{ runner.os }}-buildx-
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
if: github.event.inputs.registry != 'dockerhub'
|
if: ${{ inputs.push_to_ghcr }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
@@ -62,35 +64,29 @@ jobs:
|
|||||||
password: ${{ secrets.GHCR_TOKEN }}
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
if: github.event.inputs.registry == 'dockerhub'
|
if: ${{ inputs.push_to_dockerhub }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: bugattiguy527
|
username: bugattiguy527
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Determine Docker image tag
|
- name: Determine Docker image tags
|
||||||
|
id: vars
|
||||||
run: |
|
run: |
|
||||||
REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
|
REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
|
||||||
echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_ENV
|
echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_ENV
|
||||||
|
|
||||||
if [ "${{ github.event.inputs.tag_name }}" != "" ]; then
|
if [ "${{ github.event.inputs.tag_name }}" != "" ]; then
|
||||||
IMAGE_TAG="${{ github.event.inputs.tag_name }}"
|
IFS=',' read -ra TAGS <<< "${{ github.event.inputs.tag_name }}"
|
||||||
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
||||||
IMAGE_TAG="latest"
|
TAGS=("latest")
|
||||||
elif [ "${{ github.ref }}" == "refs/heads/development" ]; then
|
elif [ "${{ github.ref }}" == "refs/heads/development" ]; then
|
||||||
IMAGE_TAG="development-latest"
|
TAGS=("development-latest")
|
||||||
else
|
else
|
||||||
IMAGE_TAG="${{ github.ref_name }}"
|
TAGS=("${{ github.ref_name }}")
|
||||||
fi
|
fi
|
||||||
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
if [ "${{ github.event.inputs.registry }}" == "dockerhub" ]; then
|
echo "TAGS=${TAGS[*]}" >> $GITHUB_ENV
|
||||||
echo "REGISTRY=docker.io" >> $GITHUB_ENV
|
|
||||||
echo "IMAGE_NAME=bugattiguy527/termix" >> $GITHUB_ENV
|
|
||||||
else
|
|
||||||
echo "REGISTRY=ghcr.io" >> $GITHUB_ENV
|
|
||||||
echo "IMAGE_NAME=lukegus/termix" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Build and Push Multi-Arch Docker Image
|
- name: Build and Push Multi-Arch Docker Image
|
||||||
uses: useblacksmith/build-push-action@v2
|
uses: useblacksmith/build-push-action@v2
|
||||||
@@ -98,8 +94,10 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: ./docker/Dockerfile
|
file: ./docker/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
|
tags: |
|
||||||
|
${{ inputs.push_to_ghcr && format('ghcr.io/lukegus/termix:{0}', join(fromJson('["' + replace(env.TAGS, " ", '","') + '"]'), '\nghcr.io/lukegus/termix:')) }}
|
||||||
|
${{ inputs.push_to_dockerhub && format('docker.io/bugattiguy527/termix:{0}', join(fromJson('["' + replace(env.TAGS, " ", '","') + '"]'), '\ndocker.io/bugattiguy527/termix:')) }}
|
||||||
labels: |
|
labels: |
|
||||||
org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
||||||
org.opencontainers.image.revision=${{ github.sha }}
|
org.opencontainers.image.revision=${{ github.sha }}
|
||||||
|
|||||||
Reference in New Issue
Block a user