ci: Push to mirror repo with github actions

This commit is contained in:
Ahmad Ansori Palembani 2024-12-05 12:03:18 +07:00
parent cd978388b2
commit 0406160452
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

47
.github/workflows/mirror.yml vendored Normal file
View file

@ -0,0 +1,47 @@
# REF: https://github.com/JamesRobionyRogers/GitHub-to-GitBucket-Action/blob/47a44e9/.github/workflows/push-to-gitbucket.yml
name: Mirror Repository
on:
workflow_dispatch:
push:
branches:
- master
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Fetch all branches
run: |
git fetch --all
git fetch --tags
- name: List branches
run: |
git branch -a
# Enables tracking of remote branches ensuring all branches are pushed to mirror repo
- name: Track remote branches
run: |
for branch in $(git branch -r | grep -v '\->'); do
local_branch=${branch#origin/}
git branch --track "$local_branch" "$branch" || true
done
- name: Push to mirror repo (GitLab)
env:
MIRROR_URL: "gitlab.com/null2264/yokai.git"
MIRROR_USERNAME: ${{ secrets.MIRROR_USERNAME }}
MIRROR_AUTH: ${{ secrets.MIRROR_AUTH }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git remote add mirror https://$MIRROR_USERNAME:$MIRROR_AUTH@$MIRROR_URL
git push --mirror -v mirror