-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (31 loc) · 938 Bytes
/
sync-to-gitlab.yml
File metadata and controls
35 lines (31 loc) · 938 Bytes
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
name: Sync to GitLab
on:
push:
branches: ["*"]
tags: ["*"]
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sync to GitLab
shell: bash
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_REPO: ${{ secrets.GITLAB_REPO }}
run: |
git remote remove gitlab 2>/dev/null || true
CLEAN_URL=$(echo "$GITLAB_REPO" | sed 's|https://||')
AUTH_URL="https://oauth2:${GITLAB_TOKEN}@${CLEAN_URL}"
git branch -r | grep -v '\->' | while read -r 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"