-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (73 loc) · 2.58 KB
/
update.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: update packages
on:
push:
paths:
- '.github/workflows/wall.yml'
- '.github/Plugins/main.sh'
schedule:
- cron: '0 0 * * *'
repository_dispatch:
workflow_dispatch:
inputs:
packages:
description: 'packages'
required: false
default: 'false'
jobs:
build:
if: github.event.repository.owner.id == github.event.sender.id || ! github.event.sender.id
runs-on: ubuntu-latest
name: Update ${{matrix.target}}
strategy:
fail-fast: false
matrix:
target: [main]
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Initialization environment
run : |
git config --global user.email "${{ secrets.GH_MAIL }}"
git config --global user.name "${{ secrets.GH_NAME }}"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Clone packages
run: |
cd $GITHUB_WORKSPACE
chmod +x .github/Plugins/${{matrix.target}}.sh
git clone -b ${{matrix.target}} https://github.com/mzwrt/mzwrt_package.git ${{matrix.target}}
cd ${{matrix.target}}
git rm -r --cache * >/dev/null 2>&1 &
rm -rf `find ./* -maxdepth 0 -type d ! -name "Plugins"` >/dev/null 2>&1
$GITHUB_WORKSPACE/.github/Plugins/${{matrix.target}}.sh
bash /$GITHUB_WORKSPACE/.github/patches/patch.sh
bash /$GITHUB_WORKSPACE/.github/Plugins/convert_translation.sh
bash /$GITHUB_WORKSPACE/.github/Plugins/create_acl_for_luci.sh -a
bash /$GITHUB_WORKSPACE/.github/Plugins/Modify.sh
- name: 提交更改并推送到远程仓库
run: |
if [ -e $GITHUB_WORKSPACE/LICENSE ]; then
cp $GITHUB_WORKSPACE/LICENSE $GITHUB_WORKSPACE/${{matrix.target}}
fi
if [ -e $GITHUB_WORKSPACE/README.md ]; then
cp $GITHUB_WORKSPACE/README.md $GITHUB_WORKSPACE/${{matrix.target}}
fi
cd $GITHUB_WORKSPACE/${{matrix.target}}
if git status --porcelain | grep -q .; then
echo "Adding changes to git..."
git add .
git commit -am "update $(date '+%Y-%m-%d %H:%M:%S')"
echo "Pushing changes to GitHub..."
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} HEAD:main
else
echo "nothing to commit"
exit 0
fi || exit 0
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 1