-
Notifications
You must be signed in to change notification settings - Fork 15
46 lines (46 loc) · 1.49 KB
/
sync_mirror.yml
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
on:
workflow_dispatch:
schedule:
- cron: '0 */8 * * *'
name: Sync Mirror
jobs:
run:
name: Sync Mirror
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
path: original
- run: |
# setup key
echo "$SSH_KEY" > .git_ssh_key
chmod 600 .git_ssh_key
# setup repo
set -x
mkdir mirror
cd mirror
git init --initial-branch=master
git remote add origin [email protected]:hoilc/scoop-lemon.git
git config user.name 'github-actions[bot]'
git config user.email '[email protected]'
git config core.sshCommand "ssh -o StrictHostKeyChecking=no -i $GITHUB_WORKSPACE/.git_ssh_key"
git fetch
git checkout master
# merge original
git remote add original $GITHUB_WORKSPACE/original
git fetch original
git merge original/master -Xtheirs || true
git diff --name-only --diff-filter=U | xargs git rm || true
git commit -m "(chore): merge original [scoop skip]" || true
# substitute
sed -i 's,"url": "https://github.com/,"url": "https://mirror.ghproxy.com/https://github.com/,g' $GITHUB_WORKSPACE/original/bucket/*.json
# sync
rsync -av --delete --cvs-exclude $GITHUB_WORKSPACE/original/ .
# push
git add -A
git commit -m "(chore): update mirror [scoop skip]" || true
git push
env:
SSH_KEY: ${{ secrets.CODEBERG_SSH_KEY }}