name: Mirror to other platforms on: push: branches: - '**' workflow_dispatch: jobs: mirror: runs-on: ubuntu-latest name: Mirror Repository steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up SSH uses: webfactory/ssh-agent@v0.8.0 with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - name: Add known hosts run: | mkdir -p ~/.ssh ssh-keyscan gitlab.com >> ~/.ssh/known_hosts ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts ssh-keyscan codeberg.org >> ~/.ssh/known_hosts - name: Mirror to GitLab run: | git config --global user.name "github-actions[bot]" git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" # Get list of local branches LOCAL_BRANCHES=$(git branch | grep -v "origin/" | tr -d '* ' | tr '\n' ' ') # Mirror to the Pages project of both the user and the group namespace for repo in tiennm99/tiennm99.gitlab.io miti99/miti99.gitlab.io; do remote="gitlab-${repo%%/*}" # Add GitLab remote git remote add "$remote" "git@gitlab.com:$repo.git" # Fetch from GitLab to get information about the default branch git fetch "$remote" # Push each local branch individually to GitLab for branch in $LOCAL_BRANCHES; do git push "$remote" "$branch:$branch" --force done # Push all tags git push "$remote" --tags --force done - name: Mirror to Bitbucket run: | # Add Bitbucket remote git remote add bitbucket git@bitbucket.org:miti99/miti99.bitbucket.io.git # Fetch from Bitbucket to get information about the default branch git fetch bitbucket # Get current branch name CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) # Get list of local branches LOCAL_BRANCHES=$(git branch | grep -v "origin/" | tr -d '* ' | tr '\n' ' ') # Push each local branch individually to Bitbucket for branch in $LOCAL_BRANCHES; do # Push branch to Bitbucket git push bitbucket $branch:$branch --force done # Push all tags git push bitbucket --tags --force - name: Mirror to Codeberg run: | # Add Codeberg remote git remote add codeberg ssh://git@codeberg.org/miti99/pages.git # Fetch from Codeberg to get information about the default branch git fetch codeberg # Get list of local branches LOCAL_BRANCHES=$(git branch | grep -v "origin/" | tr -d '* ' | tr '\n' ' ') # Push each local branch individually to Codeberg for branch in $LOCAL_BRANCHES; do # Push branch to Codeberg git push codeberg $branch:$branch --force done # Push all tags git push codeberg --tags --force