Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/copilot-ci-failure-handler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Auto-summon Copilot on CI Failure"

on:
workflow_run:
workflows:
- "CI"
- "CodeQL Analysis"
- "SonarCloud Analysis"
types:
- completed

jobs:
notify-copilot-ci:
name: Notify Copilot on Build Failure
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request'
permissions:
pull-requests: write
issues: write

steps:
- name: Comment on PR to Summon Copilot
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
RUN_URL: ${{ github.event.workflow_run.html_url }}
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
run: |
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
echo "CI workflow '${WORKFLOW_NAME}' failed for PR #${PR_NUMBER}."
gh pr comment "${PR_NUMBER}" \
--body "@copilot The workflow **${WORKFLOW_NAME}** failed on this pull request. Please inspect the build failure logs at ${RUN_URL}, fix the issue, and commit the update."
else
echo "No associated pull request found for this workflow run."
fi
27 changes: 27 additions & 0 deletions .github/workflows/copilot-review-handler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Auto-summon Copilot on Review Changes Requested"

on:
pull_request_review:
types:
- submitted

jobs:
dispatch-copilot:
name: Notify Copilot of Review Feedback
runs-on: ubuntu-latest
# Only trigger when a review explicitly requests changes
if: github.event.review.state == 'changes_requested'
permissions:
pull-requests: write
issues: write

steps:
- name: Comment on PR to Summon Copilot
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REVIEWER: ${{ github.event.review.user.login }}
run: |
echo "Review submitted requesting changes by @${REVIEWER} on PR #${PR_NUMBER}."
gh pr comment "${PR_NUMBER}" \
--body "@copilot Changes were requested on this pull request by @${REVIEWER}. Please review the feedback, implement the necessary corrections, and push an update."
51 changes: 51 additions & 0 deletions .github/workflows/pr-automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "PR Lifecycle Automation"

on:
pull_request_target:
types:
- opened
- converted_to_draft
- edited
- labeled

jobs:
manage-pr:
name: Manage PR State & Auto-merge
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
# 1. Undraft: If PR is a draft and doesn't start with [WIP], mark it as ready for review
- name: Mark Draft as Ready for Review
if: github.event.pull_request.draft == true && !startsWith(github.event.pull_request.title, '[WIP]')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NODE_ID: ${{ github.event.pull_request.node_id }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
echo "Marking PR #${PR_NUMBER} as ready for review..."
gh api graphql -f query='
mutation($id: ID!) {
markPullRequestReadyForReview(input: {pullRequestId: $id}) {
pullRequest {
id
isDraft
}
}
}
' -f id="${PR_NODE_ID}"

# 2. Auto-merge: If PR is open, not draft, not WIP, and authored by repo member/collaborator/owner, enable auto-merge (squash)
- name: Enable Auto-Merge
if: |
github.event.pull_request.state == 'open' &&
!startsWith(github.event.pull_request.title, '[WIP]') &&
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
echo "Enabling auto-merge for PR #${PR_NUMBER}..."
gh pr merge "${PR_NUMBER}" --auto --squash || echo "Auto-merge could not be enabled (may already be enabled or repo settings require manual merge)."
Comment thread
Copilot marked this conversation as resolved.
35 changes: 0 additions & 35 deletions .github/workflows/ready-for-review.yml

This file was deleted.

Loading