如何根据输出条件 运行 一个 Github 动作的步骤?

How to run a Github Action's step based on output condition?

如果 flake8 错误超过 100 个,我想对 PR 发表评论,但不会禁用合并按钮。

我的做法是这样的:

name: Flake8 Check
on:  [pull_request]

jobs:
  flake8:
    name: Flake8 Check
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v2

      - name: Install Python
        uses: actions/setup-python@v1
        with:
          python-version: 3.6

      - name: Install dependency
        run: pip install flake8

      - name: Flake8
        id: flake
        run: echo "::set-output name=number::$(flake8 --config=tools/dev/.flake8 --count -qq)"


      - name: comment PR
        uses: unsplash/comment-on-pr@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          msg: "There are ${{ steps.flake.outputs.number }} Flake8 errors which is a lot :disappointed: \nThis will not block you to merge it but please try to fix them."
          check_for_duplicate_msg: true
        if: ${{ steps.flake.outputs.number }} > 100 

然而,即使有不到 100 个错误,它也在评论。我检查了 documentation,我认为它是正确的。

我缺少什么?

contexts, they recommend not using ${{ }} in the condition of the if context, although they also show 的 github 操作页面上,使用 ${{ }} 语法的 if 条件,但我想它实际上并没有像您在此处显示的那样工作.

因此,在您的情况下,您需要将 if 更改为:

if: steps.flake.outputs.number > 100