-
Notifications
You must be signed in to change notification settings - Fork 0
docs: migrate user guides to GitHub Wiki #8
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
base: main
Are you sure you want to change the base?
Changes from all commits
b46c678
9c5be4c
1f9b743
4d9666e
411bfb5
225421b
324cc65
8f64d5c
b3e0b35
0150791
71d8d3a
ca4208e
616a7a5
6f53933
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| # Validates branch protection settings weekly and creates issues if configuration problems are found. | ||
| # Checks for required settings like PR reviews, status checks, and other security configurations. | ||
| name: Branch Protection Check | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 0 * * 1" # Weekly on Monday | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
|
|
||
| concurrency: | ||
| group: branch-protection-check-${{ github.workflow }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| check: | ||
| name: Check Branch Protection | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Check branch protection rules | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const branch = 'main'; | ||
|
|
||
| // Helper function to find or create/update issues (DRY principle) | ||
|
||
| async function findOrCreateIssue(titleFragment, issueBody, labels) { | ||
| const { data: existingIssues } = await github.rest.issues.listForRepo({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: 'open', | ||
| labels: labels, | ||
| per_page: 10 | ||
| }); | ||
|
|
||
| const existingIssue = existingIssues.find(issue => | ||
| issue.title.includes(titleFragment) | ||
| ); | ||
|
|
||
| if (existingIssue) { | ||
| // Update existing issue | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: existingIssue.number, | ||
| body: `## π Updated Check Results\n\n${issueBody}` | ||
| }); | ||
| console.log(`Updated existing issue #${existingIssue.number}`); | ||
| } else { | ||
| // Create new issue | ||
| await github.rest.issues.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: `${titleFragment} for ${branch}`, | ||
| body: issueBody, | ||
| labels: labels | ||
| }); | ||
| console.log('Created new issue'); | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| const { data: protection } = await github.rest.repos.getBranchProtection({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| branch: branch | ||
| }); | ||
|
|
||
| console.log('β Branch protection is enabled for', branch); | ||
| console.log('Protection rules:', JSON.stringify(protection, null, 2)); | ||
|
|
||
| // Check required settings | ||
| const issues = []; | ||
|
|
||
| if (!protection.required_pull_request_reviews) { | ||
| issues.push('β Pull request reviews are not required'); | ||
| } | ||
|
|
||
| if (!protection.enforce_admins?.enabled) { | ||
| issues.push('β οΈ Rules do not apply to administrators'); | ||
| } | ||
|
|
||
| if (!protection.required_status_checks) { | ||
| issues.push('β οΈ No required status checks configured'); | ||
| } | ||
|
|
||
| if (issues.length > 0) { | ||
| console.log('\nβ οΈ Issues found:'); | ||
| issues.forEach(issue => console.log(issue)); | ||
|
|
||
| const issueBody = `## Branch Protection Check Results\n\nThe following issues were found with branch protection for \`${branch}\`:\n\n${issues.map(i => `- ${i}`).join('\n')}\n\n**Recommendations:**\n- Enable pull request reviews\n- Apply rules to administrators\n- Configure required status checks\n\n---\n*Automated check run on ${new Date().toISOString()}*`; | ||
|
|
||
| await findOrCreateIssue('Branch Protection Configuration Issues', issueBody, ['security', 'branch-protection', 'chore']); | ||
| } else { | ||
| console.log('\nβ All branch protection checks passed!'); | ||
| } | ||
|
|
||
| } catch (error) { | ||
| if (error.status === 404) { | ||
| console.error(`β No branch protection found for ${branch}`); | ||
|
|
||
| const issueBody = `## β οΈ Branch Protection Missing\n\nBranch protection is not configured for \`${branch}\`.\n\n**Recommended settings:**\n- Require pull request reviews\n- Require status checks to pass\n- Enforce rules for administrators\n- Require linear history\n\n---\n*Automated check run on ${new Date().toISOString()}*`; | ||
|
|
||
| await findOrCreateIssue('Branch Protection Not Configured', issueBody, ['security', 'branch-protection', 'priority: high']); | ||
| } else { | ||
| throw error; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,6 @@ | ||||||||||
| # Comprehensive CI workflow with linting, type checking, testing, and building. | ||||||||||
| # Supports Node.js version matrix testing and optional coverage upload. | ||||||||||
| # All steps are optional and can be configured individually. | ||||||||||
| name: CI | ||||||||||
|
|
||||||||||
| on: | ||||||||||
|
|
@@ -9,6 +12,12 @@ on: | |||||||||
| If not specified, the version will be read from package.json. | ||||||||||
| type: string | ||||||||||
| required: false | ||||||||||
| node-version-matrix: | ||||||||||
| description: | | ||||||||||
| JSON array of Node.js versions to test against (e.g. '["18", "20", "22"]') | ||||||||||
| If specified, overrides node-version and runs tests across multiple versions. | ||||||||||
| type: string | ||||||||||
| required: false | ||||||||||
| pnpm-version: | ||||||||||
| description: | | ||||||||||
| The version of pnpm to use (supports the Semantic Versioning Specification, e.g. 8, 10.7.0, latest) | ||||||||||
|
|
@@ -105,15 +114,20 @@ jobs: | |||||||||
| run: ${{ inputs.typecheck-command }} | ||||||||||
|
|
||||||||||
| test: | ||||||||||
| name: Test | ||||||||||
| name: Test${{ inputs.node-version-matrix && format(' (Node {0})', matrix.node-version) || '' }} | ||||||||||
| if: inputs.run-test | ||||||||||
| runs-on: ubuntu-latest | ||||||||||
| timeout-minutes: 15 | ||||||||||
| strategy: | ||||||||||
| fail-fast: false | ||||||||||
| matrix: | ||||||||||
|
||||||||||
| matrix: | |
| matrix: | |
| # If inputs.node-version-matrix is set, use it as the matrix. | |
| # Otherwise, use a single node version (inputs.node-version or 'default'). |
Copilot
AI
Oct 1, 2025
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.
The complex conditional logic for determining node-version creates a hard-to-read expression. Consider extracting this logic into a separate step or simplifying the approach.
Copilot
AI
Oct 1, 2025
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.
The use of 'default' as a magic string and the conditional logic makes this expression unclear. Consider using a more explicit approach or documenting the 'default' value behavior.
| node-version: ${{ matrix.node-version != 'default' && matrix.node-version || inputs.node-version }} | |
| # Use matrix.node-version if set, otherwise fall back to inputs.node-version | |
| node-version: ${{ matrix.node-version && matrix.node-version != '' && matrix.node-version || inputs.node-version }} |
Copilot
AI
Oct 1, 2025
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.
The use of 'default' as a magic string value makes the logic unclear. Consider using a more explicit approach or documenting why 'default' is used as a sentinel value.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Automatically reviews dependencies for security vulnerabilities in pull requests. | ||
| # Configurable severity thresholds, license checking, and PR comment settings. | ||
| name: Dependency Review | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| fail-on-severity: | ||
| description: 'Minimum severity to fail the check (low, moderate, high, critical)' | ||
| type: string | ||
| default: 'moderate' | ||
| required: false | ||
| comment-summary-in-pr: | ||
| description: 'Whether to comment summary in PR (always, on-failure, never)' | ||
| type: string | ||
| default: 'always' | ||
| required: false | ||
| allow-licenses: | ||
| description: 'Comma-separated list of allowed licenses' | ||
| type: string | ||
| required: false | ||
| deny-licenses: | ||
| description: 'Comma-separated list of denied licenses' | ||
| type: string | ||
| required: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: dependency-review-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| dependency-review: | ||
| name: Review Dependencies | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Dependency Review | ||
| uses: actions/dependency-review-action@v4 | ||
| with: | ||
| fail-on-severity: ${{ inputs.fail-on-severity }} | ||
| comment-summary-in-pr: ${{ inputs.comment-summary-in-pr }} | ||
| allow-licenses: ${{ inputs.allow-licenses }} | ||
| deny-licenses: ${{ inputs.deny-licenses }} |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,33 +20,74 @@ jobs: | |||||||
| runs-on: ubuntu-latest | ||||||||
| timeout-minutes: 5 | ||||||||
| steps: | ||||||||
| - name: Greet on first PR | ||||||||
| if: github.event_name == 'pull_request_target' | ||||||||
| uses: actions/first-interaction@v1 | ||||||||
| - name: Greet first-time contributors | ||||||||
| uses: actions/github-script@v7 | ||||||||
| with: | ||||||||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||||||||
| pr-message: | | ||||||||
| π Thanks for opening your first pull request! We're excited to have you contribute. | ||||||||
| script: | | ||||||||
| const issue_number = context.issue.number; | ||||||||
| const is_pr = context.eventName === 'pull_request_target'; | ||||||||
|
|
||||||||
| A maintainer will review your PR soon. In the meantime, please make sure: | ||||||||
| - [ ] Your code follows the project's style guidelines | ||||||||
| - [ ] You've added tests if applicable | ||||||||
| - [ ] You've updated documentation if needed | ||||||||
| - [ ] All CI checks pass | ||||||||
| // Get the author | ||||||||
| const author = context.payload.sender.login; | ||||||||
|
|
||||||||
| Feel free to ask questions if you need any help! π | ||||||||
| // Check if this is the author's first contribution | ||||||||
| // Note: Fetching up to 100 items should be sufficient for most repositories. | ||||||||
| // For extremely active repos, this might miss older contributions, but it's a reasonable tradeoff. | ||||||||
|
||||||||
| // For extremely active repos, this might miss older contributions, but it's a reasonable tradeoff. | |
| // For extremely active repos, this might miss older contributions, but it's a reasonable tradeoff. | |
| // Limiting to 100 items also helps avoid excessive API requests, improving efficiency and reducing the risk of hitting API rate limits. |
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.
This workflow file is missing a descriptive comment at the top explaining its purpose. Add a comment similar to other workflows to maintain consistency.