-
-
Notifications
You must be signed in to change notification settings - Fork 366
Closed
Labels
Description
Description
See #5951 for full context.
We need to migrate all workflows using the on.[event].paths
filtering to use a files-changed
job using dorny/paths-filter
instead. To enforce required checks we need to add a required check job at the end, which always runs and is used as the main indicator for required checks.
An example implementation is done for tests.yml
and api-stability.yml
, reference PR is #5893
Use the following prompt to create a draft PR:
Do the following for these variables:
[WORKFLOW_NAME] = "Auto Update Tools"
[WORKFLOW_KEY] = "auto_update_tools"
[WORKFLOW_FILE] = "auto-update-tools"
Use the file-filters at .github/file-filters.yml and the test workflow .github/workflows/test.yml as reference on how we added a check to enforce unit-tests-required-check. Then create the same for the [WORKFLOW_NAME] workflow:
Requirements:
1. **Add file filter**: Create a new filter called `run_[WORKFLOW_KEY]_for_prs` in .github/file-filters.yml containing all file paths from the workflow's current `on.pull_request.paths` (if it exists, otherwise include relevant paths for that workflow)
2. **Modify workflow**: Update .github/workflows/[WORKFLOW_FILE].yml to:
- Add `files-changed` job that detects file changes using the new filter
- Make the main job(s) conditional with `if: needs.files-changed.outputs.run_[WORKFLOW_KEY]_for_prs == 'true'` and `needs: files-changed`
- Add `[WORKFLOW_KEY]-required-check` job at the end that validates completion using `if: always()` pattern
- **IMPORTANT**: Do NOT change the workflow triggers (`on:`) or concurrency settings - only add file detection and required check
3. **Follow the exact pattern**: Use the unit-tests-required-check implementation as the template for job structure, naming, and logic.
The goal is to make the workflow run conditionally based on file changes while providing a reliable required check that can be used in branch protection rules.