Create GitHub Actions workflows for CI, automation, or PR management. Use when asked to create, scaffold, or add a GitHub Actions workflow (.yml file under .github/workflows/).
Create and configure GitHub Actions workflows that follow this repository's conventions and patterns. Workflows automate tasks like CI validation, PR management, issue labeling, and notifications.
This repository uses specific patterns across all workflows. Follow these conventions when creating new workflows:
.github/workflows/label-and-milestone-issues.yml, validate-pr-target-branch.ymlubuntu-latest for general-purpose jobsubuntu-24.04 when a specific OS version is needed (e.g., copilot setup steps)permissions: {}pull-requests: writeissues: writecontents: readpull_request_target instead of pull_request
pull_request_target workflows run in the base repository context with its permissions. Do not check out or execute code from the PR branch in these workflows. Instead, use the event payload and/or GitHub API (actions/github-script, github.rest.*, etc.) to inspect and act on the PR safely.actions/github-script@v8 for complex logic instead of shell scriptsasync/await — the github object (Octokit) and context are availablegithub.rest.* for REST API calls and github.graphql() for GraphQL queriescontext.payload.pull_request, context.repo.owner, context.repo.repoconsole.log() for debugging; use core.setFailed() for errorsBefore writing the workflow, clarify:
| Use case | Event | Notes |
|---|---|---|
| PR opened/updated | pull_request | Read-only access to PR |
| PR with write access | pull_request_target | Can comment, label, close |
| PR merged | pull_request_target: [closed] | Check github.event.pull_request.merged == true |
| CI checks complete | check_suite: [completed] | Filter app.slug != 'github-actions' to skip self |
| Code pushed | push | Filter by branches/paths |
| Manual trigger | workflow_dispatch | Add inputs: for parameters |
| Scheduled | schedule | Use cron syntax |
Create the YAML file following this template:
# Description of what this workflow does and why.