BIGFA commited on
Commit
b52bb01
·
verified ·
1 Parent(s): 5658195

Create .github/workflows/build_docker.yml

Browse files
Files changed (1) hide show
  1. .github/workflows/build_docker.yml +62 -0
.github/workflows/build_docker.yml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build and Push Docker Image
2
+
3
+ on:
4
+ release:
5
+ types: [created] # 表示在创建新的 Release 时触发
6
+ workflow_dispatch: # 手动触发(可选)
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout repository
14
+ uses: actions/checkout@v3
15
+
16
+ - name: List files in the repository
17
+ run: ls -la # 列出文件以确保必要的文件存在
18
+
19
+ - name: Disable Docker BuildKit
20
+ run: echo "DOCKER_BUILDKIT=0" >> $GITHUB_ENV
21
+
22
+ - name: Set up Docker Buildx
23
+ uses: docker/setup-buildx-action@v2
24
+
25
+ - name: Log in to Docker Hub
26
+ uses: docker/login-action@v2
27
+ with:
28
+ username: ${{ secrets.DOCKER_HUB_USERNAME }}
29
+ password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
30
+
31
+ - name: Log in to GitHub Container Registry
32
+ uses: docker/login-action@v2
33
+ with:
34
+ registry: ghcr.io
35
+ username: ${{ github.actor }}
36
+ password: ${{ secrets.GITHUB_TOKEN }}
37
+
38
+ - name: Convert GitHub username to lowercase
39
+ id: lowercase_username
40
+ run: echo "username=$(echo ${{ github.actor }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
41
+
42
+ - name: Build and push to Docker Hub
43
+ uses: docker/build-push-action@v4
44
+ with:
45
+ context: .
46
+ push: true
47
+ tags: ${{ secrets.DOCKER_HUB_USERNAME }}/ddg-chat-go:latest
48
+ platforms: linux/amd64,linux/arm64
49
+ labels: |
50
+ version=latest
51
+ maintainers=https://blog.lmyself.top
52
+
53
+ - name: Build and push to GitHub Packages
54
+ uses: docker/build-push-action@v4
55
+ with:
56
+ context: .
57
+ push: true
58
+ tags: ghcr.io/${{ env.username }}/ddg-chat-go:latest
59
+ platforms: linux/amd64,linux/arm64
60
+ labels: |
61
+ version=latest
62
+ maintainers=https://blog.lmyself.top