Skip to content

Commit e76c038

Browse files
authored
Fix bug of secrets token, use GITHUB_TOKEN instead
1 parent f74de73 commit e76c038

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,38 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write # 新增:赋予写入内容的权限
12+
1013
steps:
11-
- uses: actions/checkout@v2
12-
- uses: actions/setup-python@v1
14+
- uses: actions/checkout@v4 # 升级到最新版本
15+
- uses: actions/setup-python@v5 # 升级到最新版本
1316
with:
14-
python-version: 3.10.18
17+
python-version: '3.10' # 简化版本号,使用最新的3.10.x
18+
1519
- name: install python modules
1620
run: pip install flake8 markdown pypinyin
1721
#- name: format code
18-
# run: flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics
22+
# run: flake8 . --count --select=E9,F63,F72,F82 --show-
1923
- name: generate information
2024
run: |
2125
python3 utils/genReadme.py
2226
python3 utils/genIndex.py
27+
2328
- name: git config
2429
run: |
25-
git config --global user.name "mbinary"
30+
git config --global user.name "heqin-zhu"
2631
git config --global user.email "zhuheqin1@gmail.com"
32+
2733
- name: generate pages and push to gh-pages branch
28-
env:
29-
ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}}
3034
run: |
3135
cd docs
3236
git init
33-
git remote add origin git@github.com:USTC-Resource/USTC-Course.git
37+
# 使用HTTPS协议而非SSH,避免密钥问题
38+
git remote add origin https://github.com/USTC-Resource/USTC-Course.git
3439
git add --all
3540
export TZ='Asia/Shanghai'
36-
git commit -m "Update webpages at `date +%Y-%m-%d,%H:%m` UTC+8"
37-
git push -f "https://${ACCESS_TOKEN}@github.com/USTC-Resource/USTC-Course" master:gh-pages
38-
41+
git commit -m "Update webpages at `date +%Y-%m-%d,%H:%M` UTC+8" # 修复时间格式错误(%m改为%M)
42+
43+
# 使用GitHub官方令牌和推荐的认证格式
44+
git push -f "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/USTC-Resource/USTC-Course.git" HEAD:gh-pages

0 commit comments

Comments
 (0)