自动生成首页Readme中的脚本文件清单,无需再人工修改,请勿删除Readme中隐藏状态的标记行。

This commit is contained in:
EvineDeng
2021-01-24 15:50:08 +08:00
parent 6bedd599ab
commit 866dc3ba24
3 changed files with 72 additions and 5 deletions

35
.github/workflows/update_list.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: update_list
on:
workflow_dispatch:
schedule:
- cron: '1 5,17 * * *'
repository_dispatch:
types: update_list
#push:
# branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: ${{ github.repository }}
- name: "更新Readme中脚本清单列表"
run: |
bash update_list.sh
- name: commit
run: |
git config --global user.email ${{ secrets.EMAIL }}
git config --global user.name lxk0301
git add .
git commit -m "更新Readme中脚本清单列表 by lxk0301 Github Action" -a || echo "Nothing to update"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.TOKEN }}
branch: master

View File

@ -27,6 +27,9 @@
2. 以字母排序。
<!-- 这是隐藏信息,用来给 update_list.sh 脚本提供标记信息的,用于自动生成下面的脚本清单,请勿删除这里的标记信息。 -->
<!-- 此表格由 update_list.sh 脚本自动生成,请不要人工修改。 -->
<!-- 清单标记开始 -->
| 活动时长 | 名称 | 脚本 |
| -------- | --------------------------------- | -------------------------------------------------------------------------------------------------------- |
| 长期 | 京豆变动通知 | [jd_bean_change.js](https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_bean_change.js) |
@ -73,18 +76,18 @@
| 长期 | 注销京东会员卡 | [jd_unbind.js](https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_unbind.js) |
| 长期 | 取关京东店铺和商品 | [jd_unsubscribe.js](https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_unsubscribe.js) |
| 长期 | 京喜签到 | [jx_sign.js](https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jx_sign.js) |
<!-- 清单标记结束 -->
<!-- 此表格由 update_list.sh 脚本自动生成,请不要人工修改。 -->
<!-- 这是隐藏信息,用来给 update_list.sh 脚本提供标记信息的,用于自动生成上面的脚本清单,请勿删除这里的标记信息。 -->
#### 搬运脚本
搬运脚本
1. 【[@yangtingxiao](https://github.com/yangtingxiao)】京东抽奖机([jd_lotteryMachine.js](https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_lotteryMachine.js))
2. 【[@yangtingxiao](https://github.com/yangtingxiao)】京东排行榜([jd_rankingList.js](https://raw.githubusercontent.com/LXK9301/jd_scripts/master/jd_rankingList.js))
**脚本兼容: [QuantumultX](https://apps.apple.com/us/app/quantumult-x/id1443988620), [Surge](https://apps.apple.com/us/app/surge-4/id1442620678), [Loon](https://apps.apple.com/us/app/loon/id1373567447), 小火箭, JSBox, Node.js**
**TODO**
- [x] 所有活动互助码在一个脚本打印
## 邀请码互助
- [邀请码互助入口](https://github.com/LXK9301/jd_scripts/discussions)
@ -126,9 +129,11 @@
### 4. iOS代理软件QuantumultX, Surge, Loon, 小火箭)
##### 获取京东cookie
- [京东cookie获取脚本 JD_extra_cookie.js](https://raw.githubusercontent.com/LXK9301/jd_scripts/master/JD_extra_cookie.js)
##### 订阅链接:
- SurgeTask&Cookies脚本模块地址: https://raw.githubusercontent.com/LXK9301/jd_scripts/master/Surge/lxk0301_Task.sgmodule.sgmodule
- LoonTask&Cookies脚本订阅链接: https://raw.githubusercontent.com/LXK9301/jd_scripts/master/Loon/lxk0301_LoonTask.conf
@ -136,6 +141,7 @@
- QuantumultX Task脚本订阅链接: https://raw.githubusercontent.com/LXK9301/jd_scripts/master/QuantumultX/lxk0301_gallery.json
- QuantumultX cookie脚本订阅链接: https://raw.githubusercontent.com/LXK9301/jd_scripts/master/QuantumultX/lxk0301_cookies.conf
## 赞赏码(开发维护不易,请赏杯茶水费)
<div align=center><img width="250" height="250" src="./icon/thanks.jpg"/></div>

26
update_list.sh Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
## 网址、路径、文件、标记信息以及表头
WorkDir=$(cd $(dirname $0); pwd)
JsList=($(cd $WorkDir; ls *.js | grep -E "j[drx]_"))
FileReadme=$WorkDir/README.md
UrlBlob=https://github.com/LXK9301/jd_scripts/blob/master/
UrlRaw=https://raw.githubusercontent.com/LXK9301/jd_scripts/master/
SheetHead="| 序号 | 名称 | blob文件链接 | raw文件链接 |\n| ---- | ------- | ------------ | ----------- |"
## 删除标记行的内容
StartLine=$(($(grep -n "标记开始" "$FileReadme" | awk -F ":" '{print $1}') + 1))
EndLine=$(($(grep -n "标记结束" "$FileReadme" | awk -F ":" '{print $1}') - 1))
Tail=$(perl -ne "$. > $EndLine && print" "$FileReadme")
perl -i -ne "{print unless $StartLine .. eof}" "$FileReadme"
## 生成新的表格并写入Readme
cd $WorkDir
Sheet=$SheetHead
for ((i=0; i<${#JsList[*]}; i++)); do
Name=$(grep "new Env" ${JsList[i]} | awk -F "'|\"" '{print $2}')
Blob="$UrlBlob${JsList[i]}"
Raw="$UrlRaw${JsList[i]}"
Sheet="$Sheet\n| $(($i + 1)) | $Name | [${JsList[i]}]($Blob) | [${JsList[i]}]($Raw) |"
done
echo -e "$Sheet\n$Tail" >> $FileReadme