Repository navigation
ci: add PR lifecycle automation and on-demand Copilot dispatch workflows #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)." | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.