Build & Deploy #67
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: Build & Deploy | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
schedule: | |
# 每天 5:30 UTC 触发工作流程 | |
- cron: '30 5 * * *' | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: 'https://registry.npmjs.org' | |
- run: npm install | |
- run: npm start | |
- name: Configure git | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git stash | |
git pull --rebase | |
git stash pop | |
git add data/badge.json data/data.json data/package-stats.json | |
git diff-index --quiet HEAD || git commit -m 'ci: Update npm-stat data' | |
git push | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./dist | |
user_name: github-actions[bot] | |
user_email: github-actions[bot]@users.noreply.github.com |