-
Notifications
You must be signed in to change notification settings - Fork 2
41 lines (34 loc) · 1.26 KB
/
backup.yml
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
name: Mirror to GitLab
on:
push:
branches:
- main
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Verify GitLab Repository
env:
GITLAB_ACCESS_TOKEN: ${{ secrets.GITLAB_ACCESS_TOKEN }}
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }}
GITLAB_REPOSITORY: ${{ secrets.GITLAB_REPOSITORY }}
run: |
git config --global user.name 'Maruf Bepary'
git config --global user.email '[email protected]'
git ls-remote https://oauth2:${GITLAB_ACCESS_TOKEN}@gitlab.com/${GITLAB_USERNAME}/${GITLAB_REPOSITORY}.git HEAD
if [ $? -ne 0 ]; then
echo "Failed to connect to GitLab repository. Check if repository exists and credentials/token are correct."
exit 1
fi
- name: Mirror Repository to GitLab
env:
GITLAB_ACCESS_TOKEN: ${{ secrets.GITLAB_ACCESS_TOKEN }}
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }}
GITLAB_REPOSITORY: ${{ secrets.GITLAB_REPOSITORY }}
run: |
git remote add gitlab https://oauth2:${GITLAB_ACCESS_TOKEN}@gitlab.com/${GITLAB_USERNAME}/${GITLAB_REPOSITORY}.git || true
git push --force gitlab main