| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- # 当分支 main 有 push 事件并且此次 push 包含了 components 目录下的文件时,执行以下任务
- # 使用 GitHub Actions secrets 存储的 NPM_TOKEN 自动将本仓库 components 目录下的所有文件发布到 npm 上
- name: Auto publish npm
- on:
- push:
- branches:
- - main
- paths:
- - 'components/**'
- jobs:
- publish:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v2
- # 读取最新push的 tag 内容,如果是 v 开头,则往下执行,否则退出
- # - name: Check tag
- # run: |
- # if [[ $GITHUB_REF != 'refs/tags/v'* ]]; then
- # echo "This is not a tag push. Skipping."
- # exit 78
- # fi
- - name: Setup Node.js environment
- uses: actions/setup-node@v1
- with:
- node-version: 18.x
- - name: Publish
- run: |
- cd components
- npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
- npm publish
- env:
- CI: true
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|