Let’s Get Certified
Module 02 / 15 · Workflow authoring

Select a workflow event and its permissions

Choose between scheduled, manual, external and repository events, then pass a constrained request into a reusable job.

A release requested by operations

A release operator must explicitly select test or production. An external monitoring ping must never start that release. What should the author declare and where does deployment authority belong?

Work through the decision

Use workflow_dispatch with a required choice input. Map its validated value into a callable workflow with a declared input. Bind the production deployment job to its protected environment, and grant only that job its required access. Keep monitoring on its own event and credential path.

Trigger the intended run

Use schedule for recurring work on the default branch, workflow_dispatch for a person or API initiating an on-demand run, and repository_dispatch for custom external events. A pull_request workflow can filter base branches, paths and activity types. Several events can start separate runs.

A schedule follows the default branch. For manual dispatch, the workflow definition must exist on the default branch to receive the event. In a pull request, the head contains the change and the base is the destination. Check which of these refs the event supplies before deciding which code to test.

Match authority to the event

Keep read-only CI for contributor changes separate from jobs that publish approved releases. Restrict publish permissions to the publishing job and the intended event or environment. An event filter selects when work is eligible. Token permissions limit what that work may do.

Validate typed inputs across calls

Declare choice, boolean or other supported manual inputs and check meaningful bounds before acting. The inputs context preserves typed booleans. A callable workflow declares its own input types and named secrets. Map values through the caller job's with and secrets keys.

Interface fragment for a workflow called by another job. The caller passes the boolean under with and maps the separately declared secret under secrets. Inspect the boolean with inputs.publish.

on:
  workflow_call:
    inputs:
      publish:
        type: boolean
        required: true
    secrets:
      registry_key:
        required: true

The check that disappeared

A PR from docs-fix targets main. The workflow listens for pushes to docs-fix and pull requests into docs-fix. Why is there no matching PR run for main?

Check your reasoning

For pull_request the branches filter inspects the base, which is main. Adjust the intended PR filter and examine path filters as well. A push run on the head branch is a different event and need not have the same ref or permissions.

GitHub documentation · GH-200 skills outline

Continue in GitHub Foundations. Take a contribution from a local edit to review.

Knowledge check

Select a workflow event and its permissions quiz

Answer 5 questions. Check each answer for an explanation.