How to set context within workflow for retrieval of commit status

I can refer to commit status via context in general, like i.e.

$ gh api repos/kubevirt/project-infra/commits/740b8081d3240b82b4fcaa427d8573c9dddfd091/status | jq '.statuses[]| [ .context, .description ] | .'
[
  "dco",
  "All commits have Signed-off-by"
]
[
  "check-prow-config",
  "Job succeeded."
]
[
  "pull-project-infra-check-testgrid-config",
  "Job succeeded."
]
[
  "pull-project-infra-prow-deploy-test",
  "Job succeeded."
]
[
  "tide",
  "Not mergeable. Retesting: check-prow-config prow-deploy-test"
]

Then i.e. I can take the context name as an input for a branch protection, i.e. making the check pull-project-infra-prow-deploy-test required

How can I (when creating a new workflow for a GitHub Action) create a context I can reference in order to be able to make that check required?

:wave: Hey @dhiller,

If I’ve understood the question correctly, you want to create a new workflow and have the status checks from that workflow be required.

In a workflow, each job that you define in the jobs: section will create a check that you can set as required. The name of that job will match the name of the context that you’ll want to use when setting up your required checks.

So for example, if I have a pull request workflow as follows

name: Pull Request Workflow

on:
  pull_request:

jobs:
  build:

    steps:
      - run: echo "Hello world"

The job name build will be the name of the required status check.

Note that for the status checks to show up in your settings, you’ll need to run your workflow at least once.

1 Like