update:config.yaml.example #73
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: AutoFilm Builder | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
APP_VERSION: | |
description: '版本号,用于 Docker 标签' | |
required: false | |
IS_USE_LATEST_TAG: | |
description: '是否使用latest标签' | |
default: true | |
type: boolean | |
IS_USE_VERSION_TAG: | |
description: '是否使用版本标签' | |
default: true | |
type: boolean | |
env: | |
IS_USE_LATEST_TAG: false | |
IS_USE_VERSION_TAG: 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 | |
- name: Check Version Change | |
run: | | |
if git diff --name-only ${{ github.sha }} | grep 'app/version.py'; then | |
echo "IS_USE_LATEST_TAG=true" >> $GITHUB_ENV | |
echo "IS_USE_VERSION_TAG=true" >> $GITHUB_ENV | |
fi | |
- name: Set Version Tag | |
if: ${{ github.event.inputs.APP_VERSION }} | |
run: | | |
echo "传入了APP_VERSION" | |
echo "APP_VERSION=${{ github.event.inputs.APP_VERSION }}" >> $GITHUB_ENV | |
echo "IS_USE_LATEST_TAG=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: Use Version Tag | |
if: ${{ github.event.inputs.IS_USE_VERSION_TAG }} | |
run: | | |
echo "使用版本标签" | |
echo "IS_USE_VERSION_TAG=true" >> $GITHUB_ENV | |
- name: Show Env | |
run: | | |
echo "APP_VERSION=$APP_VERSION" | |
echo "IS_USE_LATEST_TAG=$IS_USE_LATEST_TAG" | |
echo "IS_USE_VERSION_TAG=$IS_USE_VERSION_TAG" | |
- 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_USE_VERSION_TAG }} | |
type=raw,value=DEV,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 |