Skip to content

Commit d572e1f

Browse files
committed
fix: clean workflow file encoding & logic
1 parent 5a4c602 commit d572e1f

File tree

1 file changed

+32
-41
lines changed

1 file changed

+32
-41
lines changed
Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,32 @@
1-
name: Sync to GitLab
2-
3-
on:
4-
push:
5-
branches: ["*"]
6-
tags: ["*"]
7-
8-
jobs:
9-
sync:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Checkout source
13-
uses: actions/checkout@v4
14-
with:
15-
fetch-depth: 0
16-
17-
- name: Set up Git
18-
run: |
19-
git config --global user.name "github-actions"
20-
git config --global user.email "actions@github.com"
21-
22-
- name: Push all branches and tags to GitLab
23-
env:
24-
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
25-
GITLAB_REPO: ${{ secrets.GITLAB_REPO }}
26-
run: |
27-
git remote remove gitlab 2>/dev/null || true
28-
29-
# GitLab縺ョ隱崎ィシURL繧剃ス懈・
30-
AUTH_URL="https://oauth2:${GITLAB_TOKEN}@${GITLAB_REPO#https://}"
31-
32-
# 蜈ィ縺ヲ縺ョ繝ェ繝「繝シ繝郁ソス霍。繝悶Λ繝ウ繝√r繝ュ繝シ繧ォ繝ォ繝悶Λ繝ウ繝√↓縺吶k・・rigin/xxx -> xxx・・
33-
# 窶サ縺薙l縺ォ繧医jrefs/remotes/origin/* 縺碁€∽ソ。諡貞凄縺輔l繧九お繝ゥ繝シ繧貞屓驕ソ
34-
git branch -r | grep -v '\->' | while read remote; do
35-
branch="${remote#origin/}"
36-
git branch -f "$branch" "$remote" 2>/dev/null || true
37-
done
38-
39-
# 蜈ィ繝悶Λ繝ウ繝√→繧ソ繧ー繧貞シキ蛻カ繝励ャ繧キ繝・
40-
git push --all --force "$AUTH_URL"
41-
git push --tags --force "$AUTH_URL"
1+
name: Sync to GitLab
2+
3+
on:
4+
push:
5+
branches: ["*"]
6+
tags: ["*"]
7+
workflow_dispatch:
8+
9+
jobs:
10+
sync:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout source
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Sync to GitLab
19+
shell: bash
20+
env:
21+
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
22+
GITLAB_REPO: ${{ secrets.GITLAB_REPO }}
23+
run: |
24+
git remote remove gitlab 2>/dev/null || true
25+
CLEAN_URL=$(echo "$GITLAB_REPO" | sed 's|https://||')
26+
AUTH_URL="https://oauth2:${GITLAB_TOKEN}@${CLEAN_URL}"
27+
git branch -r | grep -v '\->' | while read -r remote; do
28+
branch="${remote#origin/}"
29+
git branch -f "$branch" "$remote" 2>/dev/null || true
30+
done
31+
git push --all --force "$AUTH_URL"
32+
git push --tags --force "$AUTH_URL"

0 commit comments

Comments
 (0)