Skip to content

Mirror Repository

Mirror Repository #914

Workflow file for this run

name: Mirror Repository
on:
push:
branches: [ master ] # Change this to match your default branch name (main, master, etc.)
schedule:
- cron: '0 */12 * * *' # Backup sync every 12 hours
jobs:
check_repository:
runs-on: ubuntu-latest
outputs:
is_mirror: ${{ steps.check.outputs.is_mirror }}
steps:
- name: Check if mirror repository
id: check
run: |
REPO_NAME="${GITHUB_REPOSITORY}"
if [[ "$REPO_NAME" == "AdvancedPhotonSource/MIDAS" ]]; then
echo "is_mirror=true" >> $GITHUB_OUTPUT
echo "This is the mirror repository. Skipping the mirror action."
else
echo "is_mirror=false" >> $GITHUB_OUTPUT
echo "This is the source repository. Proceeding with mirroring."
fi
mirror:
needs: check_repository
if: needs.check_repository.outputs.is_mirror != 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Get all history, branches and tags
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Push to organization repository
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "[email protected]"
# Making sure we disable strict host key checking
mkdir -p ~/.ssh
echo "Host github.com" > ~/.ssh/config
echo " StrictHostKeyChecking no" >> ~/.ssh/config
git remote add organization [email protected]:AdvancedPhotonSource/MIDAS.git
git push organization --mirror