1- name : Sync Github To Image
1+ name : Sync Github To Image (External)
22
33on :
4+ push :
5+ branches :
6+ - ' **'
7+ tags-ignore :
8+ - ' **'
49 workflow_run :
510 workflows : ["Publish Release"] # 监听的工作流名称
611 types :
712 - completed # 监听完成事件
8- push :
9- branches : [main]
1013 # schedule:
1114 # 定时任务,每天 UTC 时间 0 点运行
1215 # - cron: "0 0 * * *"
1316 workflow_dispatch :
1417
15-
1618jobs :
17- sync-gitlink :
18- runs-on : ubuntu-latest
19-
20- steps :
21- - name : Checkout code
22- uses : actions/checkout@v4
23- with :
24- fetch-depth : 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
25-
26- - name : Set up Git user
27- run : |
28- git config --global user.email "[email protected] " 29- git config --global user.name "AlianBlank"
30-
31- - name : Set SSH
32- run : |
33- mkdir -p ~/.ssh
34- echo "${{ secrets.GITLINK_ID_RSA }}" >> ~/.ssh/id_rsa
35- chmod 600 ~/.ssh/id_rsa
36- eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
37- # 信任域名
38- ssh-keyscan -H code.gitlink.org.cn >> ~/.ssh/known_hosts
39-
40- # 查看当前分支
41- - name : Check current branch
42- run : echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
43-
44- # 查看远端 地址
45- - name : echo git url
46- run :
echo [email protected] :${{ github.Repository }}.git 47-
48- # 添加远端
49- - name : add remote url
50- run :
git remote add mirror "[email protected] :${{ github.Repository }}.git" 51-
52- # 获取
53- - name : fetch
54- run : git fetch --prune mirror --tags --verbose
55-
56- # 拉取和推送
57- - name : pull and push
58- run : |
59- if [ "${{ github.ref_name }}" ]; then
60- git checkout ${{ github.ref_name }}
61- git push -f mirror ${{ github.ref_name }}
62- git push -f mirror --tags --verbose
63- fi
64-
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 "[email protected] " 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 [email protected] :${{ github.Repository }}.git 94-
95- # 添加远端
96- - name : add remote url
97- run :
git remote add mirror "[email protected] :${{ github.Repository }}.git" 98-
99- # 获取
100- - name : fetch
101- run : git fetch --prune mirror --tags --verbose
102-
103- # 拉取和推送
104- - name : pull and push
105- run : |
106- if [ "${{ github.ref_name }}" ]; then
107- git checkout ${{ github.ref_name }}
108- git push -f mirror ${{ github.ref_name }}
109- git push -f mirror --tags --verbose
110- fi
111-
112-
11319 sync-gitee :
114- runs-on : ubuntu-latest
115-
116- steps :
117- - name : Checkout code
118- uses : actions/checkout@v4
119- with :
120- fetch-depth : 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
121-
122- - name : Set up Git user
123- run : |
124- git config --global user.email "[email protected] " 125- git config --global user.name "AlianBlank"
126-
127- - name : Set SSH
128- run : |
129- mkdir -p ~/.ssh
130- echo "${{ secrets.GITEE_ID_RSA }}" >> ~/.ssh/id_rsa
131- chmod 600 ~/.ssh/id_rsa
132- eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
133- # 信任域名
134- ssh-keyscan -H gitee.com >> ~/.ssh/known_hosts
135- # 查看当前分支
136- - name : Check current branch
137- run : echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
138- # 查看远端 地址
139- - name : echo git url
140- run :
echo [email protected] :${{ github.Repository }}.git 141-
142- # 添加远端
143- - name : add remote url
144- run :
git remote add mirror "[email protected] :${{ github.Repository }}.git" 145-
146- # 获取
147- - name : fetch
148- run : git fetch --prune mirror --tags --verbose
149-
150- # 拉取和推送
151- - name : pull and push
152- run : |
153- if [ "${{ github.ref_name }}" ]; then
154- git checkout ${{ github.ref_name }}
155- git push -f mirror ${{ github.ref_name }}
156- git push -f mirror --tags --verbose
157- fi
158-
159-
160- sync-atomgit :
161- runs-on : ubuntu-latest
162-
163- steps :
164- - name : Checkout code
165- uses : actions/checkout@v4
166- with :
167- fetch-depth : 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
168-
169- - name : Set up Git user
170- run : |
171- git config --global user.email "[email protected] " 172- git config --global user.name "AlianBlank"
173-
174- - name : Set SSH
175- run : |
176- mkdir -p ~/.ssh
177- echo "${{ secrets.ATOMGIT_ID_RSA }}" >> ~/.ssh/id_rsa
178- chmod 600 ~/.ssh/id_rsa
179- eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
180- # 信任域名
181- ssh-keyscan -H atomgit.com >> ~/.ssh/known_hosts
182- # 查看当前分支
183- - name : Check current branch
184- run : echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
185- # 查看远端 地址
186- - name : echo git url
187- run :
echo [email protected] :${{ github.Repository }}.git 188-
189- # 添加远端
190- - name : add remote url
191- run :
git remote add mirror "[email protected] :${{ github.Repository }}.git" 192-
193- # 获取
194- - name : fetch
195- run : git fetch --prune mirror --tags --verbose
196-
197- # 拉取和推送
198- - name : pull and push
199- run : |
200- if [ "${{ github.ref_name }}" ]; then
201- git checkout ${{ github.ref_name }}
202- git push -f mirror ${{ github.ref_name }}
203- git push -f mirror --tags --verbose
204- fi
205-
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 "[email protected] " 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 [email protected] :${{ github.Repository }}.git 235-
236- # 添加远端
237- - name : add remote url
238- run :
git remote add mirror "[email protected] :${{ github.Repository }}.git" 239-
240- # 获取
241- - name : fetch
242- run : git fetch --prune mirror --tags --verbose
243-
244- # 拉取和推送
245- - name : pull and push
246- run : |
247- if [ "${{ github.ref_name }}" ]; then
248- git checkout ${{ github.ref_name }}
249- git push -f mirror ${{ github.ref_name }}
250- git push -f mirror --tags --verbose
251- fi
252-
253-
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 "[email protected] " 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 [email protected] :${{ github.Repository }}.git 282-
283- # 添加远端
284- - name : add remote url
285- run :
git remote add mirror "[email protected] :${{ 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
20+ # 引用外部仓库的可重用工作流
21+ # 格式: {owner}/{repo}/.github/workflows/{filename}@{ref}
22+ uses : GameFrameX/public-github-actions/.github/workflows/sync.yml@main
23+ with :
24+ # 传递参数给外部工作流
25+ target_branch : ${{ github.ref_name }}
26+ repository_name : ${{ github.repository }}
27+ # 组织级别已配置密钥,可以使用 inherit 继承所有密钥
28+ secrets : inherit
0 commit comments