v1.8.0 #429
60
.github/workflows/docker-image.yml
vendored
60
.github/workflows/docker-image.yml
vendored
@@ -4,13 +4,13 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag_name:
|
tag_name:
|
||||||
description: "Custom tag names (comma-separated, e.g. latest,release-1.8.0,release-1.8.1)"
|
description: "Comma-separated list of tags, e.g. latest,release-1.8.0,release-1.8.1"
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
registry:
|
registry:
|
||||||
description: "Docker registry to push to"
|
description: "Docker registry to push to"
|
||||||
required: true
|
required: true
|
||||||
default: "ghcr"
|
default: "both"
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- "ghcr"
|
- "ghcr"
|
||||||
@@ -21,21 +21,17 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- uses: actions/checkout@v5
|
||||||
uses: actions/checkout@v5
|
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Set up QEMU
|
- uses: docker/setup-qemu-action@v3
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
with:
|
with:
|
||||||
platforms: arm64,arm/v7,arm/v6
|
platforms: arm64,arm/v7,arm/v6
|
||||||
|
|
||||||
- name: Setup Blacksmith Builder
|
- uses: useblacksmith/setup-docker-builder@v1
|
||||||
uses: useblacksmith/setup-docker-builder@v1
|
|
||||||
|
|
||||||
- name: Cache npm dependencies
|
- uses: actions/cache@v4
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.npm
|
~/.npm
|
||||||
@@ -45,8 +41,7 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
- name: Cache Docker layers
|
- uses: actions/cache@v4
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-cache
|
path: /tmp/.buildx-cache
|
||||||
key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ hashFiles('docker/Dockerfile') }}
|
key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ hashFiles('docker/Dockerfile') }}
|
||||||
@@ -54,25 +49,22 @@ jobs:
|
|||||||
${{ runner.os }}-buildx-${{ github.ref_name }}-
|
${{ runner.os }}-buildx-${{ github.ref_name }}-
|
||||||
${{ runner.os }}-buildx-
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- uses: docker/login-action@v3
|
||||||
if: ${{ github.event.inputs.registry == 'ghcr' || github.event.inputs.registry == 'both' }}
|
if: ${{ github.event.inputs.registry == 'ghcr' || github.event.inputs.registry == 'both' }}
|
||||||
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
|
- uses: docker/login-action@v3
|
||||||
if: ${{ github.event.inputs.registry == 'dockerhub' || github.event.inputs.registry == 'both' }}
|
if: ${{ github.event.inputs.registry == 'dockerhub' || github.event.inputs.registry == 'both' }}
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
with:
|
||||||
username: bugattiguy527
|
username: bugattiguy527
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Determine Docker image tag(s)
|
- name: Determine Docker image tags
|
||||||
id: vars
|
id: vars
|
||||||
run: |
|
run: |
|
||||||
# Determine tags array from workflow input or branch
|
|
||||||
if [ "${{ github.event.inputs.tag_name }}" != "" ]; then
|
if [ "${{ github.event.inputs.tag_name }}" != "" ]; then
|
||||||
IFS=',' read -ra RAW_TAGS <<< "${{ github.event.inputs.tag_name }}"
|
IFS=',' read -ra RAW_TAGS <<< "${{ github.event.inputs.tag_name }}"
|
||||||
TAGS=()
|
TAGS=()
|
||||||
@@ -89,33 +81,26 @@ jobs:
|
|||||||
else
|
else
|
||||||
TAGS=("${{ github.ref_name }}")
|
TAGS=("${{ github.ref_name }}")
|
||||||
fi
|
fi
|
||||||
|
TAG_ARRAY=()
|
||||||
# Build the final tag list for Docker Buildx (multi-line)
|
|
||||||
ALL_TAGS=""
|
|
||||||
for tag in "${TAGS[@]}"; do
|
for tag in "${TAGS[@]}"; do
|
||||||
if [ "${{ github.event.inputs.registry }}" == "ghcr" ]; then
|
if [ "${{ github.event.inputs.registry }}" = "ghcr" ]; then
|
||||||
ALL_TAGS+=$'\n'"ghcr.io/lukegus/termix:${tag}"
|
TAG_ARRAY+=("ghcr.io/lukegus/termix:${tag}")
|
||||||
elif [ "${{ github.event.inputs.registry }}" == "dockerhub" ]; then
|
elif [ "${{ github.event.inputs.registry }}" = "dockerhub" ]; then
|
||||||
ALL_TAGS+=$'\n'"docker.io/bugattiguy527/termix:${tag}"
|
TAG_ARRAY+=("docker.io/bugattiguy527/termix:${tag}")
|
||||||
else
|
else
|
||||||
ALL_TAGS+=$'\n'"ghcr.io/lukegus/termix:${tag}"
|
TAG_ARRAY+=("ghcr.io/lukegus/termix:${tag}")
|
||||||
ALL_TAGS+=$'\n'"docker.io/bugattiguy527/termix:${tag}"
|
TAG_ARRAY+=("docker.io/bugattiguy527/termix:${tag}")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# Trim leading newline
|
echo "tags=$(printf '%s\n' "${TAG_ARRAY[@]}" | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
|
||||||
ALL_TAGS="${ALL_TAGS#$'\n'}"
|
|
||||||
echo "ALL_TAGS=$ALL_TAGS" >> $GITHUB_ENV
|
|
||||||
echo "ALL_TAGS:"
|
|
||||||
echo "$ALL_TAGS"
|
|
||||||
|
|
||||||
- name: Build and Push Multi-Arch Docker Image
|
- uses: useblacksmith/build-push-action@v2
|
||||||
uses: useblacksmith/build-push-action@v2
|
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/Dockerfile
|
file: ./docker/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
|
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
|
||||||
tags: ${{ env.ALL_TAGS }}
|
tags: ${{ fromJSON(steps.vars.outputs.tags) }}
|
||||||
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 }}
|
||||||
@@ -124,8 +109,7 @@ jobs:
|
|||||||
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
|
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
|
||||||
outputs: type=registry,compression=zstd,compression-level=19
|
outputs: type=registry,compression=zstd,compression-level=19
|
||||||
|
|
||||||
- name: Cleanup Docker Images Locally
|
- run: |
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker image prune -af
|
docker image prune -af
|
||||||
docker system prune -af --volumes
|
docker system prune -af --volumes
|
||||||
|
if: always()
|
||||||
|
|||||||
Reference in New Issue
Block a user