-
Notifications
You must be signed in to change notification settings - Fork 5
chore: optimize production builds #2
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 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
475e914
chore: optimize production builds
troinine a604982
chore: add copilot instructions
troinine bf5956f
ci: add auto PR approval if Copilot signals a good review
troinine 291466d
docs: fix review comment
troinine 02072ab
ci: fix Copilot auto-approval workflow
troinine 26e44c4
Update .github/workflows/pr-approval.yml
troinine bde7457
ci: review fixes
troinine 08572bd
Update .github/workflows/pr-approval.yml
troinine 062589e
ci: fix broken jq syntax. add workflow triggers
troinine 0160013
ci: remove workflow_dispatch
troinine 8b1fe14
chore: remove pr-approval for now
troinine 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,63 @@ | ||
| name: Approve Copilot reviews | ||
|
|
||
| on: | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| auto-approve: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.pull_request.draft == false | ||
troinine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| steps: | ||
| - name: Check Copilot Review and Approval | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
troinine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| PR_URL: ${{ github.event.pull_request.html_url }} | ||
troinine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| REPO: ${{ github.repository }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| PR_DATA=$(gh pr view "$PR_URL" --repo "$REPO" --json reviews) | ||
|
|
||
| LATEST_COPILOT_REVIEW=$(echo "$PR_DATA" | jq -r ' | ||
| [(.reviews // [])[] | select(.author.login == "copilot-pull-request-reviewer")] | ||
| | sort_by(.submittedAt) | ||
| | last | ||
| ') | ||
troinine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if [ "$LATEST_COPILOT_REVIEW" == "null" ]; then | ||
| echo "No reviews found from copilot-pull-request-reviewer. Skipping." | ||
| exit 0 | ||
| fi | ||
|
|
||
| IS_CLEAN=$(echo "$LATEST_COPILOT_REVIEW" | jq -r ' | ||
| .body | test("Copilot reviewed \\d+ out of \\d+ changed files in this pull request and generated no new comments\\.)"; "i") | ||
| ') | ||
|
|
||
| if [ "$IS_CLEAN" != "true" ]; then | ||
| echo "Latest Copilot review does not indicate a clean state (generated no new comments)." | ||
| echo "Review Body: $(echo "$LATEST_COPILOT_REVIEW" | jq -r .body)" | ||
| exit 0 | ||
| fi | ||
|
|
||
troinine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| echo "Copilot review is clean and all threads resolved. Checking for existing approvals..." | ||
troinine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| EXISTING_APPROVAL=$(echo "$PR_DATA" | jq -r ' | ||
| [(.reviews // [])[] | select( | ||
| (.state == "APPROVED") and | ||
| (.author.login == "github-actions[bot]" or .author.login == "copilot-pull-request-reviewer") | ||
| )] | ||
| | length | ||
| ') | ||
| if [ "$EXISTING_APPROVAL" -gt 0 ]; then | ||
| echo "An approval review already exists from github-actions[bot] or copilot-pull-request-reviewer. Skipping approval." | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Copilot review is clean. Approving PR..." | ||
|
|
||
troinine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| gh pr review "$PR_URL" --repo "$REPO" --approve --body "Auto-approved based on clean Copilot review." | ||
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
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.