Skip to content

Commit 47e282a

Browse files
committed
fix: 修复版本tag异常的工作流
1 parent 568567d commit 47e282a

2 files changed

Lines changed: 211 additions & 81 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
# branches: [main]
8+
#schedule:
9+
# 定时任务,每天 UTC 时间 0 点运行
10+
#- cron: "0 0 * * *"
11+
12+
#workflow_dispatch:
13+
permissions: # Global permissions configuration starts here
14+
contents: read # 'read' access to repository contents
15+
pull-requests: write # 'write' access to pull requests
16+
17+
jobs:
18+
tags:
19+
runs-on: ubuntu-latest
20+
21+
permissions:
22+
contents: write
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
28+
29+
- name: Set up Git user
30+
run: |
31+
git config --global user.email "wangfj11@foxmail.com"
32+
git config --global user.name "AlianBlank"
33+
34+
- name: "✏️ Generate release changelog"
35+
uses: heinrichreimer/action-github-changelog-generator@v2.3
36+
with:
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Commit CHANGELOG.md
40+
run: |
41+
git add CHANGELOG.md
42+
git commit -m "[修改]1.修改更新日志"
43+
44+
- name: change-version-by-tag
45+
uses: AlianBlank/github-action-tag-version@1.0.9
46+
with:
47+
version: ${{ github.ref_name }}
48+
49+
- name: Push changes
50+
uses: ad-m/github-push-action@master
51+
with:
52+
force: true
53+
tags: true

.github/workflows/sync.yml

Lines changed: 158 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
name: Sync Github To Image
22

33
on:
4+
workflow_run:
5+
workflows: ["Publish Release"] # 监听的工作流名称
6+
types:
7+
- completed # 监听完成事件
48
push:
59
branches: [main]
6-
schedule:
7-
# 定时任务,每天 UTC 时间 20 点 50运行
8-
- cron: "50 20 * * *"
10+
#schedule:
11+
# 定时任务,每天 UTC 时间 0 点运行
12+
#- cron: "0 0 * * *"
913
workflow_dispatch:
1014

15+
1116
jobs:
1217
sync-gitlink:
1318
runs-on: ubuntu-latest
@@ -42,27 +47,69 @@ jobs:
4247

4348
# 添加远端
4449
- name: add remote url
45-
run: git remote add gitlink "git@code.gitlink.org.cn:${{ github.Repository }}.git"
50+
run: git remote add mirror "git@code.gitlink.org.cn:${{ github.Repository }}.git"
4651

4752
# 获取
4853
- name: fetch
49-
run: git fetch --prune gitlink --tags --verbose
54+
run: git fetch --prune mirror --tags --verbose
5055

51-
# 拉取
52-
- name: pull
56+
# 拉取和推送
57+
- name: pull and push
5358
run: |
5459
if [ "${{ github.ref_name }}" ]; then
5560
git checkout ${{ github.ref_name }}
56-
git pull --progress -v --no-rebase gitlink ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
61+
git push -f mirror ${{ github.ref_name }}
62+
git push -f mirror --tags --verbose
5763
fi
5864
59-
# 推送
60-
- name: push
65+
66+
sync-gitlab:
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
74+
75+
- name: Set up Git user
76+
run: |
77+
git config --global user.email "wangfj11@foxmail.com"
78+
git config --global user.name "AlianBlank"
79+
80+
- name: Set SSH
81+
run: |
82+
mkdir -p ~/.ssh
83+
echo "${{ secrets.GITLAB_ID_RSA }}" >> ~/.ssh/id_rsa
84+
chmod 600 ~/.ssh/id_rsa
85+
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
86+
# 信任域名
87+
ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
88+
# 查看当前分支
89+
- name: Check current branch
90+
run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
91+
# 查看远端 地址
92+
- name: echo git url
93+
run: echo git@gitlab.com:${{ github.Repository }}.git
94+
95+
# 添加远端
96+
- name: add remote url
97+
run: git remote add mirror "git@gitlab.com:${{ github.Repository }}.git"
98+
99+
# 获取
100+
- name: fetch
101+
run: git fetch --prune mirror --tags --verbose
102+
103+
# 拉取和推送
104+
- name: pull and push
61105
run: |
62106
if [ "${{ github.ref_name }}" ]; then
63-
git push -u --force gitlink ${{ github.ref_name }} --tags --verbose
107+
git checkout ${{ github.ref_name }}
108+
git push -f mirror ${{ github.ref_name }}
109+
git push -f mirror --tags --verbose
64110
fi
65111
112+
66113
sync-gitee:
67114
runs-on: ubuntu-latest
68115

@@ -94,26 +141,21 @@ jobs:
94141

95142
# 添加远端
96143
- name: add remote url
97-
run: git remote add gitee "git@gitee.com:${{ github.Repository }}.git"
144+
run: git remote add mirror "git@gitee.com:${{ github.Repository }}.git"
98145

99146
# 获取
100147
- name: fetch
101-
run: git fetch --prune gitee --tags --verbose
148+
run: git fetch --prune mirror --tags --verbose
102149

103-
# 拉取
104-
- name: pull
150+
# 拉取和推送
151+
- name: pull and push
105152
run: |
106153
if [ "${{ github.ref_name }}" ]; then
107154
git checkout ${{ github.ref_name }}
108-
git pull --progress -v --no-rebase gitee ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
155+
git push -f mirror ${{ github.ref_name }}
156+
git push -f mirror --tags --verbose
109157
fi
110158
111-
# 推送
112-
- name: push
113-
run: |
114-
if [ "${{ github.ref_name }}" ]; then
115-
git push -u --force gitee ${{ github.ref_name }} --tags --verbose
116-
fi
117159
118160
sync-atomgit:
119161
runs-on: ubuntu-latest
@@ -146,76 +188,111 @@ jobs:
146188

147189
# 添加远端
148190
- name: add remote url
149-
run: git remote add atomgit "git@atomgit.com:${{ github.Repository }}.git"
191+
run: git remote add mirror "git@atomgit.com:${{ github.Repository }}.git"
150192

151193
# 获取
152194
- name: fetch
153-
run: git fetch --prune atomgit --tags --verbose
195+
run: git fetch --prune mirror --tags --verbose
154196

155-
# 拉取
156-
- name: pull
197+
# 拉取和推送
198+
- name: pull and push
157199
run: |
158200
if [ "${{ github.ref_name }}" ]; then
159201
git checkout ${{ github.ref_name }}
160-
git pull --progress -v --no-rebase atomgit ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
202+
git push -f mirror ${{ github.ref_name }}
203+
git push -f mirror --tags --verbose
161204
fi
162205
163-
# 推送
164-
- name: push
206+
207+
sync-gitcode:
208+
runs-on: ubuntu-latest
209+
210+
steps:
211+
- name: Checkout code
212+
uses: actions/checkout@v4
213+
with:
214+
fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
215+
216+
- name: Set up Git user
217+
run: |
218+
git config --global user.email "wangfj11@foxmail.com"
219+
git config --global user.name "AlianBlank"
220+
221+
- name: Set SSH
222+
run: |
223+
mkdir -p ~/.ssh
224+
echo "${{ secrets.GITCODE_ID_RSA }}" >> ~/.ssh/id_rsa
225+
chmod 600 ~/.ssh/id_rsa
226+
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
227+
# 信任域名
228+
ssh-keyscan -H gitcode.net >> ~/.ssh/known_hosts
229+
# 查看当前分支
230+
- name: Check current branch
231+
run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
232+
# 查看远端 地址
233+
- name: echo git url
234+
run: echo git@gitcode.net:${{ github.Repository }}.git
235+
236+
# 添加远端
237+
- name: add remote url
238+
run: git remote add mirror "git@gitcode.net:${{ github.Repository }}.git"
239+
240+
# 获取
241+
- name: fetch
242+
run: git fetch --prune mirror --tags --verbose
243+
244+
# 拉取和推送
245+
- name: pull and push
165246
run: |
166247
if [ "${{ github.ref_name }}" ]; then
167-
git push -u --force atomgit ${{ github.ref_name }} --tags --verbose
248+
git checkout ${{ github.ref_name }}
249+
git push -f mirror ${{ github.ref_name }}
250+
git push -f mirror --tags --verbose
168251
fi
169252
170-
# sync-gitcode:
171-
# runs-on: ubuntu-latest
172-
173-
# steps:
174-
# - name: Checkout code
175-
# uses: actions/checkout@v4
176-
# with:
177-
# fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
178-
179-
# - name: Set up Git user
180-
# run: |
181-
# git config --global user.email "wangfj11@foxmail.com"
182-
# git config --global user.name "AlianBlank"
183-
184-
# - name: Set SSH
185-
# run: |
186-
# mkdir -p ~/.ssh
187-
# echo "${{ secrets.GITCODE_ID_RSA }}" >> ~/.ssh/id_rsa
188-
# chmod 600 ~/.ssh/id_rsa
189-
# eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
190-
# # 信任域名
191-
# ssh-keyscan -H gitcode.net >> ~/.ssh/known_hosts
192-
# # 查看当前分支
193-
# - name: Check current branch
194-
# run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
195-
# # 查看远端 地址
196-
# - name: echo git url
197-
# run: echo git@gitcode.net:${{ github.Repository }}.git
198-
199-
# # 添加远端
200-
# - name: add remote url
201-
# run: git remote add gitcode "git@gitcode.net:${{ github.Repository }}.git"
202-
203-
# # 获取
204-
# - name: fetch
205-
# run: git fetch --prune gitcode --tags --verbose
206-
207-
# # 拉取
208-
# - name: pull
209-
# run: |
210-
# if [ "${{ github.ref_name }}" ]; then
211-
# git checkout ${{ github.ref_name }}
212-
# git pull --progress -v --no-rebase gitcode ${{ github.ref_name }} --tags --verbose || echo 远端不存在${{ github.ref_name }}分支;
213-
# fi
214-
215-
# # 推送
216-
# - name: push
217-
# run: |
218-
# if [ "${{ github.ref_name }}" ]; then
219-
# git push -u --force gitcode ${{ github.ref_name }} --tags --verbose
220-
# fi
221253
254+
sync-framagit:
255+
runs-on: ubuntu-latest
256+
257+
steps:
258+
- name: Checkout code
259+
uses: actions/checkout@v4
260+
with:
261+
fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
262+
263+
- name: Set up Git user
264+
run: |
265+
git config --global user.email "wangfj11@foxmail.com"
266+
git config --global user.name "AlianBlank"
267+
268+
- name: Set SSH
269+
run: |
270+
mkdir -p ~/.ssh
271+
echo "${{ secrets.FRAMAGIT_ID_RSA }}" >> ~/.ssh/id_rsa
272+
chmod 600 ~/.ssh/id_rsa
273+
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
274+
# 信任域名
275+
ssh-keyscan -H framagit.org >> ~/.ssh/known_hosts
276+
# 查看当前分支
277+
- name: Check current branch
278+
run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
279+
# 查看远端 地址
280+
- name: echo git url
281+
run: echo git@framagit.org:${{ github.Repository }}.git
282+
283+
# 添加远端
284+
- name: add remote url
285+
run: git remote add mirror "git@framagit.org:${{ github.Repository }}.git"
286+
287+
# 获取
288+
- name: fetch
289+
run: git fetch --prune mirror --tags --verbose
290+
291+
# 拉取和推送
292+
- name: pull and push
293+
run: |
294+
if [ "${{ github.ref_name }}" ]; then
295+
git checkout ${{ github.ref_name }}
296+
git push -f mirror ${{ github.ref_name }}
297+
git push -f mirror --tags --verbose
298+
fi

0 commit comments

Comments
 (0)