fix: workflow
All checks were successful
images-build-and-push / build (., debian-12.dockerfile, xdu/debian:bookworm
, debian-12) (push) Successful in 1m11s
images-build-and-push / build (., debian.dockerfile, xdu/debian:latest
xdu/debian:trixie
, debian) (push) Successful in 40s
images-build-and-push / build (., ffmpeg-debian.dockerfile, xdu/ffmpeg:debian
xdu/ffmpeg:latest
, ffmpeg) (push) Successful in 3m27s
images-build-and-push / build (., ubuntu.dockerfile, xdu/ubuntu:latest
xdu/ubuntu:25.10
, ubuntu) (push) Successful in 1m13s
All checks were successful
images-build-and-push / build (., debian-12.dockerfile, xdu/debian:bookworm
, debian-12) (push) Successful in 1m11s
images-build-and-push / build (., debian.dockerfile, xdu/debian:latest
xdu/debian:trixie
, debian) (push) Successful in 40s
images-build-and-push / build (., ffmpeg-debian.dockerfile, xdu/ffmpeg:debian
xdu/ffmpeg:latest
, ffmpeg) (push) Successful in 3m27s
images-build-and-push / build (., ubuntu.dockerfile, xdu/ubuntu:latest
xdu/ubuntu:25.10
, ubuntu) (push) Successful in 1m13s
This commit is contained in:
@@ -3,6 +3,7 @@ name: images-build-and-push
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ${{ secrets.REGISTRY }}
|
REGISTRY: ${{ secrets.REGISTRY }}
|
||||||
@@ -11,64 +12,46 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- name: debian
|
- name: debian
|
||||||
context: dockerfiles
|
context: .
|
||||||
dockerfile: dockerfiles/debian.dockerfile
|
dockerfile: debian.dockerfile
|
||||||
watch: |
|
|
||||||
dockerfiles/debian.dockerfile
|
|
||||||
image: |
|
image: |
|
||||||
xdu/debian:latest
|
xdu/debian:latest
|
||||||
xdu/debian:trixie
|
xdu/debian:trixie
|
||||||
|
|
||||||
- name: debian-12
|
- name: debian-12
|
||||||
context: dockerfiles
|
context: .
|
||||||
dockerfile: dockerfiles/debian-12.dockerfile
|
dockerfile: debian-12.dockerfile
|
||||||
watch: |
|
image: |
|
||||||
dockerfiles/debian-12.dockerfile
|
|
||||||
image:
|
|
||||||
xdu/debian:bookworm
|
xdu/debian:bookworm
|
||||||
|
|
||||||
- name: ubuntu
|
- name: ubuntu
|
||||||
context: dockerfiles
|
context: .
|
||||||
dockerfile: dockerfiles/ubuntu.dockerfile
|
dockerfile: ubuntu.dockerfile
|
||||||
watch: |
|
image: |
|
||||||
dockerfiles/ubuntu.dockerfile
|
|
||||||
image:
|
|
||||||
xdu/ubuntu:latest
|
xdu/ubuntu:latest
|
||||||
xdu/ubuntu:25.10
|
xdu/ubuntu:25.10
|
||||||
|
|
||||||
|
- name: ffmpeg
|
||||||
|
context: .
|
||||||
|
dockerfile: ffmpeg-debian.dockerfile
|
||||||
|
image: |
|
||||||
|
xdu/ffmpeg:debian
|
||||||
|
xdu/ffmpeg:latest
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
- name: Decide base commit
|
fetch-depth: 1
|
||||||
id: base
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
BASE="$(git rev-parse HEAD^ 2>/dev/null || true)"
|
|
||||||
if [ -z "$BASE" ]; then BASE="$(git rev-list --max-parents=0 HEAD)"; fi
|
|
||||||
echo "base=$BASE" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Check if changed
|
|
||||||
id: changed
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
CHANGED=false
|
|
||||||
while IFS= read -r p; do
|
|
||||||
[ -z "$p" ] && continue
|
|
||||||
if git diff --name-only "${{ steps.base.outputs.base }}"...HEAD -- "$p" | grep -q .; then
|
|
||||||
CHANGED=true; break
|
|
||||||
fi
|
|
||||||
done <<< "${{ matrix.watch }}"
|
|
||||||
echo "changed=$CHANGED" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Login to registry
|
||||||
if: steps.changed.outputs.changed == 'true'
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
@@ -76,11 +59,9 @@ jobs:
|
|||||||
password: ${{ env.REGISTRY_PASSWORD }}
|
password: ${{ env.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
- name: Prepare tags & cache repo
|
- name: Prepare tags & cache repo
|
||||||
if: steps.changed.outputs.changed == 'true'
|
|
||||||
id: meta
|
id: meta
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# 将 matrix.image 多行转为带 REGISTRY 前缀的完整 tags
|
|
||||||
FULL_TAGS=""
|
FULL_TAGS=""
|
||||||
FIRST_REPO=""
|
FIRST_REPO=""
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
@@ -91,7 +72,6 @@ jobs:
|
|||||||
FIRST_REPO="${{ env.REGISTRY }}/$(echo "$line" | cut -d: -f1)"
|
FIRST_REPO="${{ env.REGISTRY }}/$(echo "$line" | cut -d: -f1)"
|
||||||
fi
|
fi
|
||||||
done <<< "${{ matrix.image }}"
|
done <<< "${{ matrix.image }}"
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "tags<<__TAGS__"
|
echo "tags<<__TAGS__"
|
||||||
printf "%s" "$FULL_TAGS"
|
printf "%s" "$FULL_TAGS"
|
||||||
@@ -99,8 +79,7 @@ jobs:
|
|||||||
echo "cache_repo=$FIRST_REPO"
|
echo "cache_repo=$FIRST_REPO"
|
||||||
} >> "$GITHUB_OUTPUT"
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Build & Push
|
- name: Build & Push (always)
|
||||||
if: steps.changed.outputs.changed == 'true'
|
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: ${{ matrix.context }}
|
context: ${{ matrix.context }}
|
||||||
@@ -109,7 +88,3 @@ jobs:
|
|||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
cache-from: type=registry,ref=${{ steps.meta.outputs.cache_repo }}:buildcache
|
cache-from: type=registry,ref=${{ steps.meta.outputs.cache_repo }}:buildcache
|
||||||
cache-to: type=registry,ref=${{ steps.meta.outputs.cache_repo }}:buildcache,mode=max
|
cache-to: type=registry,ref=${{ steps.meta.outputs.cache_repo }}:buildcache,mode=max
|
||||||
|
|
||||||
- name: Skip (no changes)
|
|
||||||
if: steps.changed.outputs.changed != 'true'
|
|
||||||
run: echo "No changes in watch list for ${{ matrix.name }}, skipping."
|
|
||||||
Reference in New Issue
Block a user