Skip to content

feat: add require-checks-in-pr composite action#113

Merged
devantler merged 2 commits intomainfrom
feat/require-checks-in-pr
Apr 20, 2026
Merged

feat: add require-checks-in-pr composite action#113
devantler merged 2 commits intomainfrom
feat/require-checks-in-pr

Conversation

@devantler
Copy link
Copy Markdown
Contributor

Description

Adds a shared composite action that aggregates the results of multiple CI jobs into a single required check. Extracted from ksail's local .github/actions/summarize-workflow.

Inputs

Input Description Required Default
job-results Space-separated list of job results to check Yes
check-name Display name used in success/failure messages No CI - Required Checks

Behavior

  • success and skipped → pass
  • failure and cancelled → fail

Motivation

Branch protection rules need a single, stable check name. This action provides that by aggregating results from matrix builds or parallel jobs.

See require-checks-in-pr/README.md for usage examples.

devantler and others added 2 commits April 20, 2026 18:45
Extracted from ksail's local .github/actions/summarize-workflow into a
shared composite action. Aggregates multiple job results into a single
required check for branch protection rules.

Inputs:
- job-results (required): space-separated list of job results
- check-name (default: "CI - Required Checks"): name for messages

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 16:45
@botantler botantler Bot enabled auto-merge (squash) April 20, 2026 16:46
@devantler devantler disabled auto-merge April 20, 2026 16:48
@devantler devantler merged commit 1f66c91 into main Apr 20, 2026
48 checks passed
@devantler devantler deleted the feat/require-checks-in-pr branch April 20, 2026 16:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a reusable composite GitHub Action to aggregate multiple job results into one required check outcome, supporting branch protection rules that need a stable check name.

Changes:

  • Introduces require-checks-in-pr composite action that fails if any dependent job failed/cancelled and passes on success/skipped.
  • Adds documentation with usage examples, inputs, and result semantics.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
require-checks-in-pr/action.yaml Implements the composite action logic to aggregate job results into a single pass/fail outcome.
require-checks-in-pr/README.md Documents motivation, usage patterns, inputs, and interpretation of job result values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +42
set -Eeuo pipefail
failed=false

for result in $JOB_RESULTS; do
case "$result" in
success|skipped)
;;
*)
failed=true
;;
esac
done
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If job-results is provided as an empty/whitespace-only string, the loop never runs and the action will incorrectly succeed. Add an explicit validation that JOB_RESULTS contains at least one non-whitespace token and fail with a clear message if it doesn't.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +43

for result in $JOB_RESULTS; do
case "$result" in
success|skipped)
;;
*)
failed=true
;;
esac
done

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default (*) branch treats any unexpected value as a failure/cancel and prints a message that may be inaccurate (e.g., typo/unknown result). Consider handling failure|cancelled explicitly, and for unknown values print an error like Unknown job result: <value> (optionally listing allowed values) and exit non-zero to make misconfigurations easier to diagnose.

Suggested change
for result in $JOB_RESULTS; do
case "$result" in
success|skipped)
;;
*)
failed=true
;;
esac
done
unknown_result=""
for result in $JOB_RESULTS; do
case "$result" in
success|skipped)
;;
failure|cancelled)
failed=true
;;
*)
unknown_result="$result"
break
;;
esac
done
if [ -n "$unknown_result" ]; then
echo "❌ $CHECK_NAME — Unknown job result: $unknown_result. Allowed values: success, failure, cancelled, skipped."
exit 1
fi

Copilot uses AI. Check for mistakes.
done

if [ "$failed" = true ]; then
echo "❌ $CHECK_NAME — at least one job failed or was cancelled."
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default (*) branch treats any unexpected value as a failure/cancel and prints a message that may be inaccurate (e.g., typo/unknown result). Consider handling failure|cancelled explicitly, and for unknown values print an error like Unknown job result: <value> (optionally listing allowed values) and exit non-zero to make misconfigurations easier to diagnose.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +35
- uses: devantler-tech/actions/require-checks-in-pr@main
with:
job-results: "${{ needs.build.result }} ${{ needs.test.result }}"
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The examples pin the action to @main, which is vulnerable to supply-chain risk and can introduce unexpected breaking changes. Prefer pinning to an immutable ref (a commit SHA) or a release tag (e.g., @v1) and update the README examples accordingly.

Copilot uses AI. Check for mistakes.
needs: [build, lint, test]
if: ${{ always() }}
steps:
- uses: devantler-tech/actions/require-checks-in-pr@main
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The examples pin the action to @main, which is vulnerable to supply-chain risk and can introduce unexpected breaking changes. Prefer pinning to an immutable ref (a commit SHA) or a release tag (e.g., @v1) and update the README examples accordingly.

Copilot uses AI. Check for mistakes.
@botantler
Copy link
Copy Markdown

botantler Bot commented Apr 20, 2026

🎉 This PR is included in version 3.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@botantler botantler Bot added the released label Apr 20, 2026
devantler added a commit that referenced this pull request Apr 20, 2026
- Fail with a clear message when job-results is empty or whitespace-only
- Handle failure|cancelled explicitly instead of relying on catch-all
- Report unknown job result values with actionable error message

Addresses review feedback from #113.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions Bot pushed a commit that referenced this pull request Apr 20, 2026
* fix: validate empty input and handle unknown job results

- Fail with a clear message when job-results is empty or whitespace-only
- Handle failure|cancelled explicitly instead of relying on catch-all
- Report unknown job result values with actionable error message

Addresses review feedback from #113.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs: pin README examples to SHA instead of @main

Pin action references to the v3.2.0 release SHA for supply-chain safety.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: address reviewer feedback on echo and allowed_values duplication

Agent-Logs-Url: https://github.com/devantler-tech/actions/sessions/a2b7624d-f1ad-4173-b521-d8c2de93ad5c

Co-authored-by: devantler <26203420+devantler@users.noreply.github.com>

* fix: use printf, disable globbing, and parse into array for robustness

- Replace echo with printf '%s\n' to avoid option misinterpretation
- Use read -r -a to parse JOB_RESULTS into an array safely
- Disable globbing with set -f to prevent wildcard expansion

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devantler <26203420+devantler@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants