Skip to content

Fix GitLab sync workflow push command #3

Fix GitLab sync workflow push command

Fix GitLab sync workflow push command #3

name: Sync to GitLab

Check failure on line 1 in .github/workflows/sync-to-gitlab.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/sync-to-gitlab.yml

Invalid workflow file

You have an error in your yaml syntax
on:
push:
branches: ["*"]
tags: ["*"]
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "github-actions"
git config --global user.email "actions@github.com"
- name: Push all branches and tags to GitLab
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_REPO: ${{ secrets.GITLAB_REPO }}
run: |
git remote remove gitlab 2>/dev/null || true
# GitLab縺ョ隱崎ィシURL繧剃ス懈・
AUTH_URL="https://oauth2:${GITLAB_TOKEN}@${GITLAB_REPO#https://}"
# 蜈ィ縺ヲ縺ョ繝ェ繝「繝シ繝郁ソス霍。繝悶Λ繝ウ繝√r繝ュ繝シ繧ォ繝ォ繝悶Λ繝ウ繝√↓縺吶k・・rigin/xxx -> xxx・・
# 窶サ縺薙l縺ォ繧医jrefs/remotes/origin/* 縺碁€∽ソ。諡貞凄縺輔l繧九お繝ゥ繝シ繧貞屓驕ソ
git branch -r | grep -v '\->' | while read remote; do
branch="${remote#origin/}"
git branch -f "$branch" "$remote" 2>/dev/null || true
done
# 蜈ィ繝悶Λ繝ウ繝√→繧ソ繧ー繧貞シキ蛻カ繝励ャ繧キ繝・
git push --all --force "$AUTH_URL"
git push --tags --force "$AUTH_URL"