Skip to content

Sync Mirror

Sync Mirror #912

Workflow file for this run

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 }}