调试ci/cd #8
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: CI | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
# 指定操作系统 | |
runs-on: ubuntu-latest | |
steps: | |
# 将代码拉到虚拟机 | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
# 指定node版本 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org/' | |
cache: 'npm' | |
# 依赖缓存策略 | |
- name: Cache | |
id: cache-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
**/node_modules | |
key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}} | |
# 依赖下载 | |
- name: Installing Dependencies | |
if: steps.cache-dependencies.outputs.cache-hit != 'true' | |
run: npm install | |
# 打包 | |
- name: Running Build | |
run: npm run build | |
# 测试 | |
# - name: Running Test | |
# run: npm run test | |
# 发布 | |
- name: Running Publish | |
run: npm publish | |
env: | |
# NPM_TOKEN is access token | |
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} |