在受保护的分支设置中,缺少 Github Action 状态检查项清单。

55

我有以下的 GitHub 动作设置,可以在创建拉取请求时很好地触发。 但它不会显示在受保护分支(主要分支)的状态检查列表中。 我不确定我做错了什么。


name: Python application

on:
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Set up Python 3.7
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
    - name: Lint with flake8
      run: |
        pip install flake8
        # stop the build if there are Python syntax errors or undefined names
        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
        flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
    - name: GitHub Action for pylint
      uses: cclauss/GitHub-Action-for-pylint@0.7.0
    - name: Github Action for pytest
      run: python3 testing.py

我也尝试使用相同的设置:

on: [ pull_request ]

编辑: 缺少检查的屏幕截图: 在此输入图片描述

3个回答

90

最后我弄清楚了。我没有为任务设置名称,因此它在这种情况下以属性构建为默认值。我正在按工作流名称搜索。一旦我添加了作业名称,我就能正确地搜索它。后来我还验证了,搜索“build”也会在列表中显示检查名称。

jobs:
  build:
    name: python test
...

3
感谢您回来回答自己的问题!我已经为整个工作流设置了名称,但它没有显示出来。:( - corysimmons
5
我的工作有名称,但在状态检查中没有列出。 - Patlatus
2
非常感谢 - 这个问题让我非常沮丧,现在终于解决了! - Amadeus Stevenson
3
你也可以省略 build:name:,只需在下一行缩进作业名称即可。然后,如果您在搜索栏中键入该名称,它将显示出来。当然,这适用于非构建情况。 - Zak Keirn
不确定为什么被接受的答案没有被置顶显示 - Steven Grant

2

我刚刚有过类似的经历,但是这是因为我的Github工作流在过去一周内没有被触发。一旦我让工作流开始运行,它就出现在搜索区域中了。


0
另一种解决方案可能是前往 https://github.com/<org_name>/<repo_name>/actions 并检查是否有一个按钮,上面写着

Enable Actions on this repository

然后尝试关闭/打开您现有的 PR 以触发该操作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接