Skip to content

update:调整程序体结构 #49

update:调整程序体结构

update:调整程序体结构 #49

Workflow file for this run

name: AutoFilm Builder
on:
push:
branches:
- main
workflow_dispatch:
inputs:
APP_VERSION:
description: '版本号,用于 Docker 标签'
required: false
IS_USE_LATEST_TAG:
description: '是否使用"latest"标签'
required: false
default: true
type: boolean
env:
IS_USE_LATEST_TAG: false
IS_APP_VERSION_CHANGE: false
jobs:
Docker-build:
runs-on: ubuntu-latest
name: Build Docker Image
steps:
- uses: actions/checkout@v4
- name: Setup
run: |
echo "APP_VERSION=$(cat app/version.py | sed -ne 's/APP_VERSION\s=\s"v\(.*\)"/\1/gp')" >> $GITHUB_ENV
echo "DEV_TAG=Dev-$(date +"%Y%m%d")" >> $GITHUB_ENV
- name: Check Version Change
run: |
if git diff --name-only ${{ github.sha }} | grep 'version.py'; then
echo "IS_APP_VERSION_CHANGE=true" >> $GITHUB_ENV
echo "IS_USE_LATEST_TAG=true" >> $GITHUB_ENV
fi
- name: Get Version from Input
if: ${{ github.event.inputs.APP_VERSION}}
run: |
echo "使用传入版本号覆盖默认版本号"
echo "传入版本号:${{ github.event.inputs.APP_VERSION }}"
echo "APP_VERSION=${{ github.event.inputs.APP_VERSION }}" >> $GITHUB_ENV
echo "IS_APP_VERSION_CHANGE=true" >> $GITHUB_ENV
- name: Use Latest Tag
if: ${{ github.event.inputs.IS_USE_LATEST_TAG }}
run: |
echo "使用latest标签"
echo "IS_USE_LATEST_TAG=true" >> $GITHUB_ENV
- name: Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/autofilm
tags: |
type=raw,value=latest,enable=${{ env.IS_USE_LATEST_TAG }}
type=raw,value=${{ env.APP_VERSION }},enable=${{ env.IS_APP_VERSION_CHANGE }}
type=raw,value=${{ env.DEV_TAG }},enable=true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: |
linux/amd64
linux/arm64/v8
push: true
build-args: |
AUTOFILM_VERSION=${{ env.APP_VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha, scope=${{ github.workflow }}-docker
cache-to: type=gha, scope=${{ github.workflow }}-docker
- name: Details Infomations
run: |
echo "现在输出详细信息"
echo "====================================="
echo "VERSION: ${{ env.APP_VERSION }}"
echo "Image: ${{ steps.meta.outputs.images }}"
echo "Tags: ${{ steps.meta.outputs.tags }}"
echo "Labels: ${{ steps.meta.outputs.labels }}"
echo "Digest: ${{ steps.meta.outputs.digests }}"
echo "Platform: ${{ steps.meta.outputs.platforms}}"