-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (46 loc) · 1.7 KB
/
Copy pathmirror.yml
File metadata and controls
51 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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/ssh-agent@v0.7.0
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 "actions@github.com"
# 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 git@github.com:AdvancedPhotonSource/MIDAS.git
git push organization --mirror