Skip to content

Commit

Permalink
Merge pull request #393 from mbeps/development
Browse files Browse the repository at this point in the history
Added experimental workflow that would backup repo into GitLab
  • Loading branch information
mbeps authored Jun 10, 2024
2 parents 8a95b13 + 26c9906 commit 8d61af7
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Mirror to GitLab

on:
push:
branches:
- main

jobs:
mirror:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Verify
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]'
# Attempt to list the remote repository
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
env:
GITLAB_ACCESS_TOKEN: ${{ secrets.GITLAB_ACCESS_TOKEN }}
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }}
GITLAB_REPOSITORY: ${{ secrets.GITLAB_REPOSITORY }}
run: |
# Setup if the initial check is successful
git remote add gitlab https://oauth2:${GITLAB_ACCESS_TOKEN}@gitlab.com/${GITLAB_USERNAME}/${GITLAB_REPOSITORY}.git
# Push code to GitLab
git push gitlab main

0 comments on commit 8d61af7

Please sign in to comment.