扫盲:科学上网 #360
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate GitBlog README | |
on: | |
workflow_dispatch: | |
issues: | |
types: [opened, edited] | |
issue_comment: | |
types: [created, edited] | |
push: | |
branches: | |
- main | |
paths: | |
- main.py | |
jobs: | |
sync: | |
name: Generate README | |
runs-on: ubuntu-latest | |
if: github.repository_owner_id == github.event.issue.user.id || github.event_name == 'push' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
cache: pip | |
cache-dependency-path: "requirements.txt" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m venv venv | |
source venv/bin/activate | |
pip install -r requirements.txt | |
# 打印当前的 Git 远程 URL | |
- name: Print Git Remote URL | |
run: git remote -v | |
# 打印当前 Git 分支 | |
- name: Print Current Branch | |
run: git branch | |
- name: Generate new md | |
run: | | |
source venv/bin/activate | |
python main.py ${{ secrets.G_T}} ${{ github.repository }} --issue_number '${{ github.event.issue.number }}' | |
# 检查 Git 状态 | |
- name: Check Git Status | |
run: git status | |
- name: Push README | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add BACKUP/*.md | |
git commit -a -m 'update new blog' || echo "nothing to commit" | |
git push || echo "nothing to push" |