Skip to content

Build README

Build README #1954

Workflow file for this run

name: Build README
on:
push:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- uses: actions/cache@v3
name: Configure npm caching
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Node.js dependencies
run: npm install
- name: Update README
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
node build.js
cat README.md
- name: Commit and push if changed
run: |
# 设置分支名称变量
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
git config user.email "[email protected]"
git config user.name "Tw93-bot"
# 添加所有变更
git add -A
# 检查是否有变更
if git diff-index --quiet HEAD --; then
echo "No changes detected"
else
git commit -m "Updated content"
git push origin "HEAD:$BRANCH_NAME"
fi