-
Notifications
You must be signed in to change notification settings - Fork 7
93 lines (80 loc) · 2.67 KB
/
auto_build_docker_container.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: 自动构建docker镜像
on:
schedule:
- cron: "36 18 * * 0"
#watch:
# types: started
# workflow_dispatch:
push:
branches: [ main ]
# pull_request:
# branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v4
# - name: Login to GHCR
# if: github.event_name != 'pull_request'
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Login to Private Docker Registry
# uses: docker/login-action@v3
# with:
# registry: ${{ secrets.DOCKER_REGISTRY }}
# username: ${{ secrets.PRIVATE_USERNAME }}
# password: ${{ secrets.PRIVATE_PASSWORD }}
- name: Get Respository Name
run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> "$GITHUB_ENV"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
# ${{ secrets.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
{{date 'YYYY/MM/DD/hh/mm/ss'}}
# type=schedule,pattern={{date 'YYYY/MM/DD'}}
# type=semver,pattern={{version}}
# type=semver,pattern=$()
# type=ref,event=branch
# type=sha
# type=ref,event=pr
# type=semver,pattern={{major}}.{{minor}}
# type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Build and push all
id: docker_build_all
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# target:
- name: all Image digest
run: echo ${{ steps.docker_build_all.outputs.digest }}