问题描述
今天配置GitHub action
的时候提示我的.yml
配置文件有语法错误
请问17行那里有什么地方写的不对么?
Invalid workflow file: .github/workflows/npm-publish.yml#L17
You have an error in your yaml syntax on line 17
on:
release:
types: [created]
push:
branches:
- master
- dev/test
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- name: CheckOut
uses: actions/checkout@v3
- name: Use Node
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
# 添加缓存,逻辑和CI Workflow里的一样
- name: Cache
id: cache-dependencies
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{hashFiles('**/pnpm-lock.yaml')}}
# 安装依赖。命中缓存则跳过此步
- name: Installing Dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
npm i pnpm -g
pnpm install
# 打包
- name: Build
run: |
cd packages/icon-vue-components
pnpm build
npm publish --access public
# - run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
大概知道什么问题了,一开始因为vscode没有装检查yml格式的插件,也没有配置
perttier
,导致不能知道问题在哪里,后来装了一个yaml
插件,就可以提示错误位置了,完整代码如下,主要是env
那里需要加一个缩进