“tilde” 在 Github Action 工作流程监听事件中的含义是什么?

huangapple go评论59阅读模式
英文:

What's the meaning of tilde in Github Action workflow listened events

问题

在GitHub Actions中,~符号在push事件行中表示不指定任何特定的触发条件,它类似于“不指定条件”或“任何条件都触发”。它确实看起来不会触发任何特定的操作,因此可以在这种情况下理解为“什么都不做”。

英文:

I found the following GitHub Actions workflow in a repository

name: Test workflow
on:
  push: ~
  pull_request:
    branches: [ dev, main ]
jobs:
  ...

I know ~ means null in YAML world, but it can represent "default value" depending on where it is used.

In GitHub Action context, what does the tilde (~) on the push event line means ? It looks like it does nothing.

答案1

得分: 1

以下是已翻译的内容:

正常的 on: 的语法 应该是:

  on: push

在这里,你需要在 on: 下面添加一个序列,因为 push 不是唯一的条件。
但是,在这种情况下,push: 本身不需要更多的参数/序列。
因此,使用 ~(空序列)作为值。

它应该与以下内容相同:

  on:
    push
英文:

The normal syntax for on: would be:

  on: push

Here, you need a sequence below on:, because push is not the only criteria.
However, push: itself does not need (in this instance) any more argument/sequence.
Hence, the ~ (empty sequence) used as a value.

It should be the same as

  on:
    push

huangapple
  • 本文由 发表于 2023年4月17日 16:24:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76033081.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定