[英]Github actions on pull request and master branch
Github actions is still in beta and pretty new, but I hope someone can help regardless. Github 动作仍处于测试阶段且相当新,但我希望有人能提供帮助。 I thought it would be possible to run github actions on the master branch and on pull requests, like this:我认为可以在主分支和拉取请求上运行 github 操作,如下所示:
on:
pull_request
push:
branches: master
But this doesn't work, and throws the error但这不起作用,并引发错误
yaml: line 4: mapping values are not allowed in this context yaml:第 4 行:在此上下文中不允许映射值
. . Instead I can only get it to work like this:相反,我只能让它像这样工作:
on: [pull_request, push]
What am I doing wrong?我究竟做错了什么? Thanks.谢谢。
I think you are just missing a colon after pull_request
.我认为您只是在pull_request
之后缺少了一个冒号。 This works for me.这对我有用。
on:
pull_request:
push:
branches: master
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Test
run: echo "done"
Explanation解释
Each trigger has to be defined as a property that defines an object.每个触发器都必须定义为定义 object 的属性。
Each object defines overrides for default settings.每个 object 都定义了默认设置的覆盖。
There are 3 possible syntax you can use:您可以使用 3 种可能的语法:
Minimal syntax:最小语法:
on:
pull_request:
push: { branches: [master] }
Explicit syntax:显式语法:
on:
pull_request: {}
push: { branches: [master] }
Extendable syntax:可扩展语法:
on:
pull_request:
push:
branches:
- master
When using a version control system the latter may be most useful as diff viewers can always easily distinguish* between different lines.当使用版本控制系统时,后者可能最有用,因为差异查看器总是可以轻松区分*不同的行。
*Although modern diff viewers can also easily distinguish inline differences. *尽管现代差异查看器也可以轻松区分内联差异。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.