-
Notifications
You must be signed in to change notification settings - Fork 49
93 lines (81 loc) · 2.97 KB
/
builder.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: AutoFilm Builder
on:
push:
branches:
- main
paths:
- version.py
workflow_dispatch:
inputs:
app_version:
description: '版本号,用于Docker标签'
required: false
use_latest:
description: '是否使用"latest"标签'
required: false
default: true
type: boolean
env:
use_latest: false
jobs:
Docker-build:
runs-on: ubuntu-latest
name: Build Docker Image
steps:
- uses: actions/checkout@v4
- name: Get Version from version.py
run: |
echo "app_version=$(cat version.py | sed -ne 's/APP_VERSION\s=\s"v\(.*\)"/\1/gp')" >> $GITHUB_ENV
- 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
- name: Get Latest Tag
if: ${{ github.event_name == 'push' }} or ${{ github.event.inputs.use_latest }}
run: |
echo "使用latest标签"
echo "use_latest=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.use_latest }}
type=raw,value=${{ env.app_version }},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}}"