@@ -13,10 +13,17 @@ jobs:
13
13
contents : read
14
14
packages : write
15
15
16
+ env :
17
+ REPOSITORY_LOWER : ${{ github.repository }}
18
+
16
19
steps :
17
20
- name : 检出代码
18
21
uses : actions/checkout@v4
19
22
23
+ - name : 将仓库名转为小写
24
+ id : lowercase
25
+ run : echo "REPOSITORY_LOWER=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
26
+
20
27
- name : 设置 Docker Buildx
21
28
uses : docker/setup-buildx-action@v3
22
29
32
39
uses : docker/metadata-action@v5
33
40
with :
34
41
images : |
35
- ghcr.io/${{ github.repository }}/backend
36
- ghcr.io/${{ github.repository }}/frontend
42
+ ghcr.io/${{ env.REPOSITORY_LOWER }}/backend
43
+ ghcr.io/${{ env.REPOSITORY_LOWER }}/frontend
37
44
tags : |
38
45
type=semver,pattern={{version}}
39
46
type=semver,pattern={{major}}.{{minor}}
45
52
with :
46
53
context : ./backend
47
54
push : true
48
- tags : ghcr.io/${{ github.repository }}/backend:${{ steps.meta.outputs.version }},ghcr.io/${{ github.repository }}/backend:latest
55
+ tags : ghcr.io/${{ env.REPOSITORY_LOWER }}/backend:${{ steps.meta.outputs.version }},ghcr.io/${{ env.REPOSITORY_LOWER }}/backend:latest
49
56
cache-from : type=gha
50
57
cache-to : type=gha,mode=max
51
58
54
61
with :
55
62
context : ./blog-web
56
63
push : true
57
- tags : ghcr.io/${{ github.repository }}/frontend:${{ steps.meta.outputs.version }},ghcr.io/${{ github.repository }}/frontend:latest
64
+ tags : ghcr.io/${{ env.REPOSITORY_LOWER }}/frontend:${{ steps.meta.outputs.version }},ghcr.io/${{ env.REPOSITORY_LOWER }}/frontend:latest
58
65
cache-from : type=gha
59
66
cache-to : type=gha,mode=max
60
67
build-args : |
@@ -64,15 +71,16 @@ jobs:
64
71
- name : 更新 Docker Compose 文件
65
72
run : |
66
73
VERSION=${{ steps.meta.outputs.version }}
67
- sed -i "s|build:\s*context: ./backend|image: ghcr.io/${{ github.repository }}/backend:${VERSION}|g" docker-compose.yml
68
- sed -i "s|build:\s*context: ./blog-web|image: ghcr.io/${{ github.repository }}/frontend:${VERSION}|g" docker-compose.yml
74
+ sed -i "s|build:\s*context: ./backend|image: ghcr.io/${REPOSITORY_LOWER}/backend:${VERSION}|g" docker-compose.yml
75
+ sed -i "s|build:\s*context: ./blog-web|image: ghcr.io/${REPOSITORY_LOWER}/frontend:${VERSION}|g" docker-compose.yml
76
+ env :
77
+ REPOSITORY_LOWER : ${{ env.REPOSITORY_LOWER }}
69
78
70
79
- name : 创建 Docker Compose 发布文件
71
- run : |
72
- cp docker-compose.yml docker-compose.release.yml
80
+ run : cp docker-compose.yml docker-compose.release.yml
73
81
74
82
- name : 上传 Docker Compose 文件作为发布资产
75
83
uses : softprops/action-gh-release@v1
76
84
with :
77
85
files : docker-compose.release.yml
78
- token : ${{ secrets.TOKEN }}
86
+ token : ${{ secrets.TOKEN }}
0 commit comments