-
-
Notifications
You must be signed in to change notification settings - Fork 109
60 lines (49 loc) · 1.66 KB
/
Copy pathmirror-gitlab.yml
File metadata and controls
60 lines (49 loc) · 1.66 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Mirror to GitLab
on:
push:
branches:
- master
workflow_dispatch: # allow manual runs
concurrency:
group: mirror-gitlab-master
cancel-in-progress: true
permissions:
contents: read
jobs:
mirror:
if: github.ref == 'refs/heads/master' # prevent other branches from mirroring
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0 # full history instead of a shallow clone
persist-credentials: false
- name: Setup SSH
env:
# private key from GitHub Actions secrets
GITLAB_SSH_KEY: ${{ secrets.GITLAB_SSH_KEY }}
run: |
# require the private key
if [[ -z "${GITLAB_SSH_KEY}" ]]; then
echo "Missing GITLAB_SSH_KEY repository secret."
exit 1
fi
# create the SSH directory
mkdir -p "${HOME}/.ssh"
chmod 700 "${HOME}/.ssh"
# write and normalize the private key
printf '%s\n' "${GITLAB_SSH_KEY}" | tr -d '\r' > "${HOME}/.ssh/gitlab"
chmod 600 "${HOME}/.ssh/gitlab"
# add GitLab to known hosts
ssh-keyscan -H gitlab.com >> "${HOME}/.ssh/known_hosts"
- name: Configure Git Remote
run: |
# add the GitLab mirror remote
git remote add gitlab git@gitlab.com:littlebizzy/slickstack.git
- name: Push to GitLab
env:
GIT_SSH_COMMAND: ssh -i "${HOME}/.ssh/gitlab" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes
run: |
# mirror GitHub master to GitLab
git push gitlab +HEAD:refs/heads/master