Skip to content

Commit 9f7f67c

Browse files
committed
ci: add GitCode mirror sync workflow
1 parent 8f46879 commit 9f7f67c

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/sync-gitcode.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Sync GitCode Mirror
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: sync-gitcode-main
10+
cancel-in-progress: true
11+
12+
jobs:
13+
sync:
14+
if: github.repository == 'LiteLDev/LeviLauncher'
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
19+
steps:
20+
- uses: actions/checkout@v6
21+
with:
22+
fetch-depth: 0
23+
persist-credentials: false
24+
25+
- name: Validate GitCode remote
26+
env:
27+
GITCODE_PUSH_URL: ${{ secrets.GITCODE_PUSH_URL }}
28+
run: |
29+
if [ -z "$GITCODE_PUSH_URL" ]; then
30+
echo "::error::Missing required secret GITCODE_PUSH_URL."
31+
exit 1
32+
fi
33+
34+
- name: Print source revision
35+
run: |
36+
echo "GitHub repository: ${{ github.repository }}"
37+
echo "GitHub ref: ${{ github.ref }}"
38+
echo "GitHub SHA: ${{ github.sha }}"
39+
40+
- name: Ensure local main branch
41+
run: |
42+
if git show-ref --verify --quiet refs/heads/main; then
43+
git checkout --force main
44+
else
45+
git checkout --force -b main origin/main
46+
fi
47+
48+
- name: Push main to GitCode
49+
env:
50+
GITCODE_PUSH_URL: ${{ secrets.GITCODE_PUSH_URL }}
51+
run: |
52+
git remote add gitcode "$GITCODE_PUSH_URL"
53+
git push gitcode refs/heads/main:refs/heads/main

0 commit comments

Comments
 (0)