-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (48 loc) · 1.58 KB
/
sync.yml
File metadata and controls
57 lines (48 loc) · 1.58 KB
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
name: Sync Github To Image
on:
push:
branches: [main]
#schedule:
# 定时任务,每天 UTC 时间 0 点运行
#- cron: "0 0 * * *"
workflow_dispatch:
jobs:
sync-gitee:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # 为了 git pull --unshallow,我们需要获取所有的提交历史
- name: Set up Git user
run: |
git config --global user.email "wangfj11@foxmail.com"
git config --global user.name "AlianBlank"
- name: Set SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.GITEE_ID_RSA }}" >> ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
# 信任域名
ssh-keyscan -H gitee.com >> ~/.ssh/known_hosts
# 查看当前分支
- name: Check current branch
run: echo 当前分支:${{ github.ref_name }} ${{ github.Repository }}
# 查看远端 地址
- name: echo git url
run: echo git@gitee.com:${{ github.Repository }}.git
# 添加远端
- name: add remote url
run: git remote add mirror "git@gitee.com:${{ github.Repository }}.git"
# 获取
- name: fetch
run: git fetch --prune mirror --tags --verbose
# 拉取和推送
- name: pull and push
run: |
if [ "${{ github.ref_name }}" ]; then
git checkout ${{ github.ref_name }}
git push -f mirror ${{ github.ref_name }}
git push -f mirror --tags --verbose
fi