Skip to content

Commit

Permalink
Update push_gitlab.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
roquelopez authored Jun 6, 2024
1 parent 6070a0e commit 1311ff1
Showing 1 changed file with 25 additions and 42 deletions.
67 changes: 25 additions & 42 deletions .github/workflows/push_gitlab.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,34 @@
name: Push to GitLab
name: Mirror to GitLab

on:
push:
branches:
- gitlab
- '*'

jobs:
push_to_gitlab:
mirror_to_gitlab:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all history to ensure all branches are included

- name: Fetch all branches and tags
run: |
git fetch --all
git fetch --tags
- name: Set up Git
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git config --global http.postBuffer 10000000 # 10 MB
- name: Add GitLab remote
env:
GITLAB_URL: ${{ secrets.GITLAB_URL }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
git remote add gitlab https://oauth2:${{ secrets.GITLAB_TOKEN }}@${{ secrets.GITLAB_URL }}
- name: Push all branches to GitLab
env:
GITLAB_URL: ${{ secrets.GITLAB_URL }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
# Push all branches
for branch in $(git for-each-ref --format '%(refname:short)' refs/heads/); do
git push gitlab $branch:$branch
done
- name: Push all tags to GitLab
env:
GITLAB_URL: ${{ secrets.GITLAB_URL }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
git push --tags gitlab
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.ref }}

- name: Set up Git
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
- name: Add GitLab remote
run: |
git remote add gitlab https://oauth2:${{ secrets.GITLAB_TOKEN }}@${{ secrets.GITLAB_URL }}
- name: Fetch all branches from GitLab
run: |
git fetch gitlab --prune
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
- name: Push all branches to GitLab
run: |
git push gitlab --all

0 comments on commit 1311ff1

Please sign in to comment.