File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 44 push :
55 branches :
66 - main
7+ paths :
8+ - ' docker/**'
9+ - ' scripts/**'
10+ - ' .github/workflows/docker.yml'
711 workflow_dispatch :
12+ inputs :
13+ versions :
14+ description : ' 要构建的版本(空格分隔,如: 2.1.0 latest)留空则构建最新3个版本+latest'
15+ required : false
16+ type : string
17+ default : ' '
818
919jobs :
1020 build :
2636 password : ${{ secrets.DOCKER_PASSWORD }}
2737
2838 - name : Build and push multi-arch images
39+ env :
40+ BUILD_VERSIONS : ${{ github.event.inputs.versions }}
2941 run : |
3042 chmod +x scripts/build-multiarch.sh
3143 bash scripts/build-multiarch.sh
Original file line number Diff line number Diff line change @@ -6,13 +6,22 @@ RELEASE_DIR="./docker"
66REPO_NAME=" doocs/md"
77PLATFORMS=" linux/amd64,linux/arm64"
88
9+ # 可以通过环境变量指定要构建的版本,用空格分隔
10+ # 例如: BUILD_VERSIONS="2.1.0 latest" ./build-multiarch.sh
11+ # 如果不指定,默认只构建最新的 3 个版本
12+ if [ -z " ${BUILD_VERSIONS:- } " ]; then
13+ BUILD_VERSIONS=$( ls -1 " $RELEASE_DIR " | grep -E ' ^[0-9]+\.[0-9]+\.[0-9]+$|^latest$' | sort -V | tail -3)
14+ BUILD_VERSIONS=" $BUILD_VERSIONS latest"
15+ fi
16+
917echo " 🔧 Multi-arch Docker build started..."
1018echo " 📁 Scanning directory: $RELEASE_DIR "
19+ echo " 🎯 Versions to build: $BUILD_VERSIONS "
1120
12- for app_ver in " $RELEASE_DIR " /* ; do
21+ for tag in $BUILD_VERSIONS ; do
22+ app_ver=" $RELEASE_DIR /$tag "
1323 [ -d " $app_ver " ] || continue
1424
15- tag=$( basename " $app_ver " )
1625 env_file=" $app_ver /.env"
1726
1827 if [ ! -f " $env_file " ]; then
You can’t perform that action at this time.
0 commit comments