forked from peiyingyao/Rule-for-OCD
-
Notifications
You must be signed in to change notification settings - Fork 6
78 lines (70 loc) · 2.6 KB
/
Copy pathci.yaml
File metadata and controls
78 lines (70 loc) · 2.6 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Build rules
on:
workflow_dispatch:
# 每天 2:32 (UTC+8) 触发一次
schedule:
- cron: '32 18 * * *'
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Add token
uses: actions/checkout@v4
with:
repository: GitMetaio/rule
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set variables
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
echo "BUILDTIME=$(TZ=Asia/Shanghai date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
echo "REPODIR=$PWD" >> $GITHUB_ENV
- name: Sync with upstream
run: |
git checkout master
git remote add upstream https://github.com/blackmatrix7/ios_rule_script.git
git fetch --depth=1 upstream
mkdir -p ./backup/
cp -f .gitignore README.md .github/workflows/ci.yaml script/convert.sh ./backup/
git merge upstream/master --strategy-option theirs --allow-unrelated-histories --no-edit
cp -f ./backup/.gitignore .gitignore
cp -f ./backup/README.md README.md
cp -f ./backup/ci.yaml .github/workflows/ci.yaml
cp -f ./backup/convert.sh script/convert.sh
- name: Background run subconverter
run: |
curl -s https://api.github.com/repos/tindy2013/subconverter/releases \
| grep "browser_download_url.*subconverter_linux64.tar.gz" \
| head -n 1 \
| cut -d '"' -f 4 \
| xargs wget -q
tar -xf subconverter_linux64.tar.gz
./subconverter/subconverter &
python3 -m http.server 8080 --bind 127.0.0.1 --directory './rule/' &
- name: Background run mihomo
run: |
curl -s https://api.github.com/repos/MetaCubeX/mihomo/releases \
| grep "browser_download_url.*mihomo-linux-amd64-alpha.*.deb" \
| head -n 1 \
| cut -d '"' -f 4 \
| xargs wget -q -O mihomo-linux-amd64-alpha.deb
sudo apt install --fix-missing ./mihomo-linux-amd64-alpha.deb
/usr/bin/mihomo &
- name: start convert
run: |
chmod +x ./script/convert.sh
./script/convert.sh
- name: Commit and Push Changes
run: |
if [ -n "$(git status --porcelain)" ]; then
git add --all
git commit -m "${{ env.BUILDTIME }} for OCD"
git push origin master
else
echo "No changes to commit"
fi