-
Notifications
You must be signed in to change notification settings - Fork 28
30 lines (27 loc) · 1.04 KB
/
mirror-to-gitlab.yml
File metadata and controls
30 lines (27 loc) · 1.04 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
name: Mirror to GitLab
on:
push:
branches: ["**"]
tags: ["**"]
jobs:
mirror:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 - https://github.com/actions/checkout/releases/tag/v5.0.0
with:
fetch-depth: 0
fetch-tags: true
persist-credentials: false
- name: Mirror to GitLab
run: |
git remote add gitlab "https://oauth2:${GITLAB_TOKEN}@${GITLAB_HOST}/${GITLAB_REPO}.git"
# Avoid --mirror, which also pushes refs/remotes/* that GitLab rejects as hidden refs.
# Push from refs/remotes/origin/* so all branches are present and --prune never deletes the default branch.
git push --prune gitlab 'refs/remotes/origin/*:refs/heads/*'
git push --force gitlab 'refs/tags/*:refs/tags/*'
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_MIRROR_TOKEN }}
GITLAB_HOST: ${{ vars.GITLAB_HOST }}
GITLAB_REPO: ${{ vars.GITLAB_REPO }}