-
Notifications
You must be signed in to change notification settings - Fork 17
chore: pr workflows #727
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?
chore: pr workflows #727
Changes from all commits
bbed53f
0bc023a
eb396f3
b450f00
f1b18c8
54815fd
de5c905
f4fb6d5
fd8b846
ca989fe
ae88880
88b7b56
31285d0
981cfae
05f1108
5f8bc30
4b43960
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,51 @@ | ||
| # https://github.com/dorny/paths-filter | ||
| python: | ||
| - "src/**" | ||
| - "pyproject.toml" | ||
| - "uv.lock" | ||
| - "**/test-integration.yml" | ||
|
|
||
| frontend: | ||
| - "frontend/**" | ||
| - "frontend/package.json" | ||
| - "frontend/package-lock.json" | ||
|
|
||
| docs: | ||
| - "docs/**" | ||
|
|
||
| docker: | ||
| - "docker-compose*.yml" | ||
| - "Dockerfile*" | ||
| - "uv.lock" | ||
| - "pyproject.toml" | ||
| - "src/**" | ||
| - "frontend/**" | ||
| - ".dockerignore" | ||
|
|
||
| tests: | ||
| - "tests/**" | ||
| - "src/**" | ||
|
|
||
| api: | ||
| - "src/api/**" | ||
| - "src/main.py" | ||
|
|
||
| services: | ||
| - "src/services/**" | ||
|
|
||
| connectors: | ||
| - "src/connectors/**" | ||
|
|
||
| flows: | ||
| - "flows/**" | ||
|
|
||
| config: | ||
| - "config/**" | ||
| - "securityconfig/**" | ||
|
|
||
| sdks: | ||
| - "sdks/**" | ||
|
|
||
| scripts: | ||
| - "scripts/**" | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| frontend: | ||
| - changed-files: | ||
| - any-glob-to-any-file: 'frontend/**' | ||
|
|
||
| backend: | ||
| - changed-files: | ||
| - any-glob-to-any-file: 'src/**' | ||
|
|
||
| documentation: | ||
| - changed-files: | ||
| - any-glob-to-any-file: 'docs/**' | ||
|
|
||
| ci: | ||
| - changed-files: | ||
| - any-glob-to-any-file: '.github/**' | ||
|
|
||
| tests: | ||
| - changed-files: | ||
| - any-glob-to-any-file: 'tests/**' | ||
|
|
||
| docker: | ||
| - changed-files: | ||
| - any-glob-to-any-file: | ||
| - 'Dockerfile*' | ||
| - 'docker-compose*.yml' | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| changelog: | ||
| categories: | ||
| - title: π¨ Breaking Changes | ||
| description: Changes that break existing functionality | ||
| labels: | ||
| - breaking | ||
| - title: β¨ New Features | ||
| description: New features and enhancements | ||
| labels: | ||
| - enhancement | ||
| - title: π Bug Fixes | ||
| description: Bug fixes and patches | ||
| labels: | ||
| - fix | ||
| - bug | ||
| - title: π Documentation Updates | ||
| description: Changes to documentation | ||
| labels: | ||
| - documentation | ||
| - title: π Maintenance Tasks | ||
| description: Maintenance tasks and housekeeping | ||
| labels: | ||
| - chore | ||
| - refactor | ||
| - style | ||
| - performance | ||
| - build | ||
| - title: β Tests | ||
| description: Changes to tests | ||
| labels: | ||
| - test | ||
| - title: Others | ||
| description: Other changes | ||
| labels: | ||
| - "*" | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| titleOnly: true | ||
| targetUrl: https://www.conventionalcommits.org/en/v1.0.0/#summary | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: Manage Review Labels | ||
|
|
||
| on: | ||
| pull_request_review: | ||
| types: [submitted] | ||
|
|
||
| jobs: | ||
| label-on-review: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| issues: write | ||
| steps: | ||
| - name: Manage LGTM Review Label | ||
| uses: actions/github-script@v8.0 | ||
| with: | ||
| script: | | ||
| const LGTM_LABEL = 'lgtm'; | ||
|
|
||
| // Extract review details | ||
| const { state: reviewState } = context.payload.review; | ||
| const pullRequestNumber = context.payload.pull_request.number; | ||
| const repoDetails = { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pullRequestNumber | ||
| }; | ||
|
|
||
| // Log review information | ||
| console.log(`Processing review for PR #${pullRequestNumber}`); | ||
| console.log(`Review state: ${reviewState}`); | ||
|
|
||
| // Helper function to check for LGTM label | ||
| async function hasLgtmLabel() { | ||
| const { data: labels } = await github.rest.issues.listLabelsOnIssue(repoDetails); | ||
| return labels.some(label => label.name === LGTM_LABEL); | ||
| } | ||
|
|
||
| if (reviewState === 'approved') { | ||
| const lgtmExists = await hasLgtmLabel(); | ||
|
|
||
| if (!lgtmExists) { | ||
| console.log(`Adding ${LGTM_LABEL} label to PR #${pullRequestNumber}`); | ||
| await github.rest.issues.addLabels({ | ||
| ...repoDetails, | ||
| labels: [LGTM_LABEL] | ||
| }); | ||
| console.log('Label added successfully'); | ||
| } else { | ||
| console.log(`${LGTM_LABEL} label already exists`); | ||
| } | ||
| } else if (reviewState === 'changes_requested') { | ||
| const lgtmExists = await hasLgtmLabel(); | ||
|
|
||
| if (lgtmExists) { | ||
| console.log(`Removing ${LGTM_LABEL} label from PR #${pullRequestNumber}`); | ||
| await github.rest.issues.removeLabel({ | ||
| ...repoDetails, | ||
| name: LGTM_LABEL | ||
| }); | ||
| console.log('Label removed successfully'); | ||
| } else { | ||
| console.log(`No ${LGTM_LABEL} label to remove`); | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Auto Delete Merged Branch | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
|
|
||
| jobs: | ||
| delete-branch: | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Delete merged branch | ||
| uses: actions/github-script@v8.0 | ||
| with: | ||
| script: | | ||
| const branchName = context.payload.pull_request.head.ref; | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
|
|
||
| // Don't delete main/master/develop branches | ||
| const protectedBranches = ['main', 'master', 'develop']; | ||
| if (protectedBranches.includes(branchName)) { | ||
| console.log(`Skipping deletion of protected branch: ${branchName}`); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| await github.rest.git.deleteRef({ | ||
| owner, | ||
| repo, | ||
| ref: `heads/${branchName}` | ||
| }); | ||
| console.log(`Successfully deleted branch: ${branchName}`); | ||
| } catch (error) { | ||
| console.log(`Could not delete branch ${branchName}: ${error.message}`); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: Add Community Label | ||
|
|
||
| on: | ||
| pull_request_target: | ||
edwinjosechittilappilly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # NOTE: pull_request_target is required to have write permissions to add labels on PRs from forks. | ||
| # This workflow must not be modified to check out or execute untrusted PR code, as it runs with base repo permissions. | ||
| types: [opened] | ||
|
|
||
| jobs: | ||
| add-label: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - name: Add community label | ||
| if: github.event.pull_request.author_association != 'MEMBER' && github.event.pull_request.author_association != 'OWNER' && github.event.pull_request.author_association != 'COLLABORATOR' | ||
| uses: actions/github-script@v8.0 | ||
| with: | ||
| script: | | ||
| const pullRequestNumber = context.payload.pull_request.number; | ||
| const repoDetails = { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pullRequestNumber | ||
| }; | ||
| await github.rest.issues.addLabels({ | ||
| ...repoDetails, | ||
| labels: ['community'] | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,76 @@ | ||||
| # NOTE: pull_request_target is required to have write permissions to add labels on PRs from forks. | ||||
| # This workflow must not be modified to check out or execute untrusted PR code, as it runs with base repo permissions. | ||||
| # the pull_request_target event. | ||||
| name: Label PRs with Conventional Commits | ||||
| on: | ||||
| pull_request_target: | ||||
| types: [opened, edited, synchronize] | ||||
edwinjosechittilappilly marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| merge_group: | ||||
|
||||
| merge_group: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| name: PR Labeler | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
|
|
||
| jobs: | ||
| labeler: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| steps: | ||
| - uses: actions/labeler@v6.0 | ||
| with: | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: PR Title Check | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, edited, synchronize, reopened] | ||
|
|
||
| jobs: | ||
| validate-title: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: amannn/action-semantic-pull-request@v6.1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| types: | | ||
| feat | ||
| fix | ||
| docs | ||
| style | ||
| refactor | ||
| perf | ||
| test | ||
| build | ||
| ci | ||
| chore | ||
| revert | ||
| requireScope: false | ||
| subjectPattern: ^.+$ | ||
|
|
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 workflow only checks if the branch name is in the protected branches list, but it doesn't verify if the branch is from a fork. For PRs from forks, the branch deletion will fail because the workflow doesn't have permission to delete branches in the fork repository. Consider adding a check to skip deletion for fork PRs:
if (context.payload.pull_request.head.repo.fork) { console.log('Skipping deletion for fork PR'); return; }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.
Good suggestion