-
Notifications
You must be signed in to change notification settings - Fork 3
83 lines (79 loc) · 3.02 KB
/
auto-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
82
83
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: auto-update
on:
push:
branches:
- "spider"
schedule:
- cron: '0 0 */1 * *'
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: run python script
run: |
python main.py
- name: Commit and push changes
id: commit
run: |
echo -e "龙芯应用合作社有应用更新啦!\n " > updatelog.txt
awk -F, '{print "-", $1, $2, $4}' loongapplist-update.csv >> updatelog.txt
git config --global user.name "Github Action"
git config --global user.email "[email protected]"
git add loongapplist-latest.csv
git commit -F updatelog.txt && git push && echo "A=1" >> $GITHUB_ENV || echo "no updates"
- name: Set date env
run: |
cp loongapplist-latest.csv loongapplist-latest-$(date '+%Y-%m-%d').csv
cp loongapplist-new.csv loongapplist-new-$(date '+%Y-%m-%d').csv
cp loongapplist-update.csv loongapplist-update-$(date '+%Y-%m-%d').csv
cp loongapplist-down.csv loongapplist-down-$(date '+%Y-%m-%d').csv
cp loongapplist-upgrade.csv loongapplist-upgrade-$(date '+%Y-%m-%d').csv
echo "TODAY=$(date '+%Y/%m/%d')" >> $GITHUB_ENV
echo "LATEST=loongapplist-latest-$(date '+%Y-%m-%d').csv" >> $GITHUB_ENV
echo "NEW=loongapplist-new-$(date '+%Y-%m-%d').csv" >> $GITHUB_ENV
echo "UPDATE=loongapplist-update-$(date '+%Y-%m-%d').csv" >> $GITHUB_ENV
echo "DOWN=loongapplist-down-$(date '+%Y-%m-%d').csv" >> $GITHUB_ENV
echo "UPGRADE=loongapplist-upgrade-$(date '+%Y-%m-%d').csv" >> $GITHUB_ENV
- name: Update Release Everyday
uses: softprops/action-gh-release@v1
if: env.A == 1
with:
files: |
${{ env.LATEST }}
${{ env.NEW }}
${{ env.UPDATE }}
${{ env.DOWN }}
${{ env.UPGRADE }}
tag_name: ${{ env.TODAY }}
name: ${{ env.TODAY }}
body_path: updatelog.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update latest Release
uses: softprops/action-gh-release@v1
if: env.A == 1
with:
files: |
loongapplist-latest.csv
loongapplist-new.csv
loongapplist-update.csv
loongapplist-down.csv
loongapplist-upgrade.csv
tag_name: latest
name: Latest
body_path: updatelog.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}