-
-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (54 loc) Β· 2.07 KB
/
Copy pathsync_with_openlist.yaml
File metadata and controls
62 lines (54 loc) Β· 2.07 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
52
53
54
55
56
57
58
59
60
61
62
name: Sync the Newest OpenList
on:
workflow_dispatch:
inputs:
upstream_repo:
description: 'Upstream repository URL'
required: true
default: 'https://github.com/OpenListTeam/OpenList.git'
type: string
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout self
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.WF_TOKEN }}
- name: Backup critical files
run: |
cp .github/workflows/sync_with_openlist.yaml /tmp/sync_with_openlist.yaml.bak
cp .github/workflows/daily.yml /tmp/daily.yml.bak
cp .github/workflows/docker.yml /tmp/docker.yml.bak
cp README.md /tmp/README.md.bak
cp README.zhcn.md /tmp/README.zhcn.md.bak
- name: Force mirror update
run: |
git remote add upstream "${{ github.event.inputs.upstream_repo }}" || true
git fetch upstream
git reset --hard upstream/main
git clean -fd -x
- name: Restore critical files
run: |
mkdir -p .github/workflows
cp /tmp/sync_with_openlist.yaml.bak .github/workflows/sync_with_openlist.yaml
cp /tmp/daily.yml.bak .github/workflows/daily.yml
cp /tmp/docker.yml.bak .github/workflows/docker.yml
cp /tmp/README.md.bak README.md
cp /tmp/README.zhcn.md.bak README.zhcn.md
- name: Commit and push
run: |
git config --global user.name "OpenList Syncer"
git config --global user.email "openlistsyncer@ilovescratch.dpdns.org"
git add .github/workflows/daily.yml
git add .github/workflows/docker.yml
git add .github/workflows/sync_with_openlist.yaml
git add README.md
git add README.zhcn.md
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git commit -m "Sync: sync the newest OpenList $(date +'%Y-%m-%d') from ${{ github.event.inputs.upstream_repo }}"
git push --force origin main
fi