This commit is contained in:
qiaofeng1227 2024-12-30 12:03:04 +08:00
commit 5908ac8d4b
4 changed files with 39 additions and 24 deletions

View File

@ -11,7 +11,7 @@ name: Build image to DockerHub
on: on:
push: push:
branches: [main] branches: [main, dev] # Include dev branch
paths: paths:
- "docker/*/Dockerfile" - "docker/*/Dockerfile"
@ -38,8 +38,7 @@ jobs:
needs: setup needs: setup
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
# You can set it to choice where download from MEDIA_FROM: "source" # You can set it to choice where download from
MEDIA_FROM: "source"
strategy: strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}} matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps: steps:
@ -53,23 +52,31 @@ jobs:
APP=${{ matrix.app }} APP=${{ matrix.app }}
TAG=$(grep 'LABEL version' "docker/$APP/Dockerfile" | cut -d'"' -f2 | xargs) TAG=$(grep 'LABEL version' "docker/$APP/Dockerfile" | cut -d'"' -f2 | xargs)
echo $APP version is $TAG echo $APP version is $TAG
if [[ "$TAG" == *"-"* ]]; then
TAGS="$TAG" # Determine the channel based on the branch and TAG
if [[ $GITHUB_REF == *"refs/heads/dev"* ]]; then
echo "CHANNEL=dev" >> $GITHUB_ENV echo "CHANNEL=dev" >> $GITHUB_ENV
TAGS="$TAG" # Use the TAG directly for dev
else else
echo "CHANNEL=release" >> $GITHUB_ENV if [[ "$TAG" == *"-"* ]]; then
IFS='.' read -ra PARTS <<< "$TAG" echo "CHANNEL=rc" >> $GITHUB_ENV
TAGS="latest" TAGS="$TAG"
TAG_PART="" else
for i in "${!PARTS[@]}"; do echo "CHANNEL=release" >> $GITHUB_ENV
if [ "$i" -eq 0 ]; then IFS='.' read -ra PARTS <<< "$TAG"
TAG_PART="${PARTS[$i]}" TAGS="latest"
else TAG_PART=""
TAG_PART="${TAG_PART}.${PARTS[$i]}" for i in "${!PARTS[@]}"; do
fi if [ "$i" -eq 0 ]; then
TAGS="${TAGS},${TAG_PART}" TAG_PART="${PARTS[$i]}"
done else
TAG_PART="${TAG_PART}.${PARTS[$i]}"
fi
TAGS="${TAGS},${TAG_PART}"
done
fi
fi fi
echo "Building and pushing Docker image for $APP with tags: $TAGS" echo "Building and pushing Docker image for $APP with tags: $TAGS"
echo "TAGS=$TAGS" >> $GITHUB_ENV echo "TAGS=$TAGS" >> $GITHUB_ENV
echo "APP=$APP" >> $GITHUB_ENV echo "APP=$APP" >> $GITHUB_ENV
@ -112,6 +119,7 @@ jobs:
repository: websoft9/docker-library repository: websoft9/docker-library
event-type: custom_event event-type: custom_event
token: ${{secrets.MYGITHUB_ADMIN_TOKEN}} token: ${{secrets.MYGITHUB_ADMIN_TOKEN}}
ref: ${{ github.ref }}
if: env.APP == 'apphub' if: env.APP == 'apphub'
# release media step1 # release media step1

View File

@ -5,6 +5,7 @@ on:
push: push:
branches: branches:
- main - main
- dev
paths: paths:
- "version.json" - "version.json"
@ -24,9 +25,13 @@ jobs:
version_core=${version%%-*} version_core=${version%%-*}
echo "VERSION=$version" >> $GITHUB_OUTPUT echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION_CORE=$version_core" >> $GITHUB_OUTPUT echo "VERSION_CORE=$version_core" >> $GITHUB_OUTPUT
if [[ $version == *-* ]]; then
echo "rc release version" if [[ $GITHUB_REF == *"refs/heads/dev"* ]]; then
echo "dev branch detected"
echo "CHANNEL=dev" >> $GITHUB_OUTPUT echo "CHANNEL=dev" >> $GITHUB_OUTPUT
elif [[ $version == *-* ]]; then
echo "rc release version"
echo "CHANNEL=rc" >> $GITHUB_OUTPUT
else else
echo "release version" echo "release version"
echo "CHANNEL=release" >> $GITHUB_OUTPUT echo "CHANNEL=release" >> $GITHUB_OUTPUT
@ -71,6 +76,7 @@ jobs:
destination-dir: ./${{ steps.convert_version.outputs.CHANNEL }}/websoft9 destination-dir: ./${{ steps.convert_version.outputs.CHANNEL }}/websoft9
- name: Create Github Release - name: Create Github Release
if: github.ref == 'refs/heads/main' # 仅在 main 分支上触发
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
with: with:
files: | files: |
@ -84,6 +90,7 @@ jobs:
pages: pages:
name: Build Github Pages name: Build Github Pages
if: github.ref == 'refs/heads/main' # 仅在 main 分支上触发
permissions: permissions:
contents: read contents: read
pages: write pages: write

View File

@ -1,11 +1,11 @@
# This file can running at actions # This file can running at actions
# MEDIA_VERSION and LIBRARY_VERSION will trigger its release # MEDIA_VERSION and LIBRARY_VERSION will trigger its release
# modify time: 202412251101, you can modify here to trigger Docker Build action # modify time: 202412291229, you can modify here to trigger Docker Build action
FROM python:3.10-slim-bullseye FROM python:3.10-slim-bullseye
LABEL maintainer="Websoft9<help@websoft9.com>" LABEL maintainer="Websoft9<help@websoft9.com>"
LABEL version="0.1.8" LABEL version="0.1.9-dev"
WORKDIR /websoft9 WORKDIR /websoft9

View File

@ -11,8 +11,8 @@
}, },
"OS": { "OS": {
"Fedora": [ "Fedora": [
"40", "41",
"39" "40"
], ],
"RedHat": [ "RedHat": [
"9", "9",