-
Notifications
You must be signed in to change notification settings - Fork 3
56 lines (47 loc) · 1.56 KB
/
sync-fork.yml
File metadata and controls
56 lines (47 loc) · 1.56 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
name: Sync Fork
on:
push:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Check repository URL
id: check_repo
run: |
CURRENT_REPO=$(git config --get remote.origin.url || echo "")
TARGET_REPO="git@github.com:Sunwuyuan/zerocat-frontend.git"
if [ "$CURRENT_REPO" = "$TARGET_REPO" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Checkout repository
if: steps.check_repo.outputs.skip != 'true'
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Install SSH key
if: steps.check_repo.outputs.skip != 'true'
uses: webfactory/ssh-agent@v0.8.0
with:
ssh-private-key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
- name: Configure Git
if: steps.check_repo.outputs.skip != 'true'
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Sync to target repository
if: steps.check_repo.outputs.skip != 'true'
run: |
# Remove all existing remotes
git remote | xargs -r git remote remove
# Add new target remote
git remote add target git@github.com:Sunwuyuan/zerocat-frontend.git
# Push all branches and tags
git push target --all --force
git push target --tags --force