Skip to content

Commit 2cacef5

Browse files
authored
Refactor GitHub Actions workflow and improve commit logic
Updated GitHub Actions workflow to use newer action versions and added workflow_dispatch trigger. Improved commit handling to avoid committing when there are no changes.
1 parent 57b9410 commit 2cacef5

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

.github/workflows/main.yml

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
1-
name: "Update Gitfolio"
1+
name: Update Gitfolio
22

33
on:
44
push:
55
branches:
66
- master
77
schedule:
88
- cron: "0 0 */3 * *"
9-
watch:
10-
types: [started]
9+
workflow_dispatch:
1110

1211
env:
1312
TZ: Asia/Shanghai
1413

1514
jobs:
1615
Gitfolio-Spider:
1716
runs-on: ubuntu-latest
17+
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v2
21-
- name: "Set up Python"
22-
uses: actions/setup-python@v1
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
2324
with:
24-
python-version: 3.10
25-
- name: "Install dependencies"
26-
run: python -m pip install --upgrade pip
27-
- name: "Install requirements"
28-
run: pip install -r ./requirements.txt
29-
- name: "Logging"
25+
python-version: "3.10"
26+
27+
- name: Install dependencies
3028
run: |
31-
echo `date +"%Y-%m-%d %H:%M:%S"` > time.log
32-
- name: "Working"
29+
python -m pip install --upgrade pip
30+
pip install -r requirements.txt
31+
32+
- name: Logging
33+
run: echo "$(date +'%Y-%m-%d %H:%M:%S')" > time.log
34+
35+
- name: Working
3336
timeout-minutes: 350
3437
run: bash ./main.sh
38+
3539
- name: Commit files
3640
run: |
3741
git config --local user.email "i@ningkai.wang"
3842
git config --local user.name "Wang Ningkai"
3943
git add -A
40-
git commit -m "Update Gitfolio at $(date +'%Y-%m-%d %H:%M')" -a
41-
- name: "Push changes"
42-
uses: ad-m/github-push-action@master
43-
with:
44-
github_token: ${{ secrets.GITHUB_TOKEN }}
45-
force: true
44+
if git diff --cached --quiet; then
45+
echo "No changes to commit"
46+
exit 0
47+
fi
48+
git commit -m "Update Gitfolio at $(date +'%Y-%m-%d %H:%M')"
49+
50+
- name: Push changes
51+
run: git push

0 commit comments

Comments
 (0)