mirror of
https://github.com/tiennm99/tiennm99.github.io.git
synced 2026-10-11 03:13:44 +00:00
78 lines
2.2 KiB
YAML
78 lines
2.2 KiB
YAML
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
|
|
|
|
- name: Mirror to GitLab
|
|
run: |
|
|
git config --global user.name "GitHub Actions"
|
|
git config --global user.email "actions@github.com"
|
|
|
|
# Add GitLab remote
|
|
git remote add gitlab git@gitlab.com:miti99/miti99.gitlab.io.git
|
|
|
|
# Fetch from GitLab to get information about the default branch
|
|
git fetch gitlab
|
|
|
|
# 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 GitLab
|
|
for branch in $LOCAL_BRANCHES; do
|
|
# Push branch to GitLab
|
|
git push gitlab $branch:$branch --force
|
|
done
|
|
|
|
# Push all tags
|
|
git push gitlab --tags --force
|
|
|
|
- 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
|