-
Notifications
You must be signed in to change notification settings - Fork 1
improved GPO & intune templates #25
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
Changes from all commits
78bd164
6d67d03
3b4cba7
60fadba
58e53ab
d2ccf37
5322d30
4cfa4d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,6 +47,8 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| lint: | ||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||||||||||||||||||||||
| uses: ./.github/workflows/lint.yml | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| test-backend: | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -58,3 +60,61 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||
| build: | ||||||||||||||||||||||||||||||||||||||||||||||
| needs: [test-backend] | ||||||||||||||||||||||||||||||||||||||||||||||
| uses: ./.github/workflows/build.yml | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| auto-merge: | ||||||||||||||||||||||||||||||||||||||||||||||
| needs: [build] | ||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||
| if: github.event_name == 'pull_request' | ||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||||||||||||||||||||||
| checks: read | ||||||||||||||||||||||||||||||||||||||||||||||
| issues: read | ||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v6 | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - name: Check Criteria and Merge | ||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||
| REPO: ${{ github.repository }} | ||||||||||||||||||||||||||||||||||||||||||||||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "Processing PR #$PR_NUMBER for Auto-Merge..." | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 1. Check CI Status | ||||||||||||||||||||||||||||||||||||||||||||||
| # Implicitly passed because this job 'needs' build/test-backend. | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "CI Orchestrator pipeline passed." | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 2. Check PR Author Permissions (Security Restriction) | ||||||||||||||||||||||||||||||||||||||||||||||
| PR_AUTHOR=$(gh pr view "$PR_NUMBER" --json author --jq '.author.login') | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "PR Author: $PR_AUTHOR" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$PR_AUTHOR" == *"[bot]" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "PR Author is a Bot. Allowed." | ||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||
| PERM=$(gh api "repos/$REPO/collaborators/$PR_AUTHOR/permission" --jq '.permission') | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "Author Permission: $PERM" | ||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$PERM" == "admin" || "$PERM" == "maintain" || "$PERM" == "write" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "Author has trusted permission ($PERM). Allowed." | ||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "::notice::PR Author ($PR_AUTHOR) does not have sufficient permissions ($PERM) for auto-merge. Skipping." | ||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 3. Check Coderabbit Status | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "Checking Coderabbit status..." | ||||||||||||||||||||||||||||||||||||||||||||||
| IS_APPROVED=$(gh api "repos/$REPO/pulls/$PR_NUMBER/reviews" --jq '.[] | select(.user.login == "coderabbitai[bot]" and .state == "APPROVED") | .state' | head -n 1) | ||||||||||||||||||||||||||||||||||||||||||||||
| HAS_SKIP_COMMENT=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "coderabbitai[bot]" and (.body | test("skip"; "i"))) | .id' | head -n 1) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -n "$IS_APPROVED" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "Coderabbit APPROVED." | ||||||||||||||||||||||||||||||||||||||||||||||
| elif [[ -n "$HAS_SKIP_COMMENT" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "Coderabbit SKIPPED review." | ||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||
| echo "::notice::Coderabbit has not approved or skipped yet. Waiting." | ||||||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+107
to
+117
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overly broad "skip" detection. The regex 🔎 Proposed fixConsider matching a specific pattern like - HAS_SKIP_COMMENT=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "coderabbitai[bot]" and (.body | test("skip"; "i"))) | .id' | head -n 1)
+ HAS_SKIP_COMMENT=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "coderabbitai[bot]" and (.body | test("<!-- skip_review -->|\\[skip\\]"; "i"))) | .id' | head -n 1)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 4. Attempt Merge | ||||||||||||||||||||||||||||||||||||||||||||||
| gh pr merge "$PR_NUMBER" --merge --auto --delete-branch | ||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,8 @@ jobs: | |||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v6 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| ref: ${{ github.head_ref || github.ref }} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v6 | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -18,4 +20,15 @@ jobs: | |||||||||||||||||||||||||||||||||||||
| run: pip install ruff | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Run Ruff (Backend) | ||||||||||||||||||||||||||||||||||||||
| run: ruff check src/ | ||||||||||||||||||||||||||||||||||||||
| run: ruff check --fix --exit-zero src/ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Commit and Push Fixes | ||||||||||||||||||||||||||||||||||||||
| if: always() | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| git config --global user.name "github-actions[bot]" | ||||||||||||||||||||||||||||||||||||||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||||||||||||||||||||
| git add src/ | ||||||||||||||||||||||||||||||||||||||
| if ! git diff --cached --quiet; then | ||||||||||||||||||||||||||||||||||||||
| git commit -m "style: auto-fix ruff linting issues" | ||||||||||||||||||||||||||||||||||||||
| git push | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Auto-commit step has potential issues.
🔎 Proposed fix - name: Commit and Push Fixes
- if: always()
+ if: success() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add src/
if ! git diff --cached --quiet; then
- git commit -m "style: auto-fix ruff linting issues"
+ git commit -m "style: auto-fix ruff linting issues [skip ci]"
git push
fi📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| name: Auto Merge (Review Listener) | ||
|
|
||
| on: | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| checks: read | ||
| issues: read | ||
| actions: read | ||
|
|
||
| jobs: | ||
| auto-merge-review: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Check Criteria and Merge | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| REPO: ${{ github.repository }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| run: | | ||
| echo "Processing PR #$PR_NUMBER for Auto-Merge (Trigger: Review)..." | ||
|
|
||
| # 1. Check CI Status (Must manually verify CI Orchestrator passed) | ||
| echo "Checking CI Status for PR #$PR_NUMBER..." | ||
| PR_HEAD_SHA=$(gh pr view "$PR_NUMBER" --json headRefOid --jq '.headRefOid') | ||
| CI_CONCLUSION=$(gh run list --commit "$PR_HEAD_SHA" --workflow "CI Orchestrator" --json conclusion --jq '.[0].conclusion') | ||
|
|
||
| if [[ "$CI_CONCLUSION" != "success" ]]; then | ||
| echo "::notice::CI Orchestrator is not 'success' (current: $CI_CONCLUSION). Skipping merge." | ||
| exit 0 | ||
| fi | ||
| echo "CI Orchestrator passed ($CI_CONCLUSION)." | ||
|
|
||
| # 2. Check PR Author Permissions | ||
| PR_AUTHOR=$(gh pr view "$PR_NUMBER" --json author --jq '.author.login') | ||
| if [[ "$PR_AUTHOR" == *"[bot]" ]]; then | ||
| echo "PR Author is a Bot. Allowed." | ||
| else | ||
| PERM=$(gh api "repos/$REPO/collaborators/$PR_AUTHOR/permission" --jq '.permission') | ||
| if [[ "$PERM" == "admin" || "$PERM" == "maintain" || "$PERM" == "write" ]]; then | ||
| echo "Author has trusted permission ($PERM). Allowed." | ||
| else | ||
| echo "::notice::PR Author ($PR_AUTHOR) does not have sufficient permissions. Skipping." | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| # 3. Check Coderabbit Status | ||
| echo "Checking Coderabbit status..." | ||
| IS_APPROVED=$(gh api "repos/$REPO/pulls/$PR_NUMBER/reviews" --jq '.[] | select(.user.login == "coderabbitai[bot]" and .state == "APPROVED") | .state' | head -n 1) | ||
| HAS_SKIP_COMMENT=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "coderabbitai[bot]" and (.body | test("skip"; "i"))) | .id' | head -n 1) | ||
|
|
||
| if [[ -n "$IS_APPROVED" ]]; then | ||
| echo "Coderabbit APPROVED." | ||
| elif [[ -n "$HAS_SKIP_COMMENT" ]]; then | ||
| echo "Coderabbit SKIPPED review." | ||
| else | ||
| echo "::notice::Coderabbit has not approved or skipped yet. Waiting." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # 4. Attempt Merge | ||
| gh pr merge "$PR_NUMBER" --merge --auto --delete-branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bot check pattern matching is incorrect.
The pattern
*[bot]in bash[[ ]]is a glob pattern, but it's case-sensitive and might not match all bot formats (e.g.,dependabot[bot]). The*before[bot]should work, but consider using a suffix check for clarity.🔎 Proposed fix
Or for more robust matching:
📝 Committable suggestion
🤖 Prompt for AI Agents