Skip to content

Commit

Permalink
[CI] Chore: Only run actions for contributors (#5739)
Browse files Browse the repository at this point in the history
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances the GitHub workflows for pull requests by adding conditions for author associations and expanding issue types.

### Detailed summary
- In `.github/workflows/auto-assign.yml`, added checks to assign authors only if they are `MEMBER`, `OWNER`, or `COLLABORATOR`.
- In `.github/workflows/issue.yml`, expanded the `types` to include `ready_for_review`.
- Added logic to automatically pass checks for external contributors.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
gregfromstl committed Dec 14, 2024
1 parent 2b5080d commit dc1e07b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ name: Auto Author Assign

on:
pull_request:
types: [ opened, reopened ]
types: [opened, reopened]

permissions:
pull-requests: write

jobs:
assign-author:
runs-on: ubuntu-latest
if: |
github.event.pull_request.author_association == 'MEMBER' ||
github.event.pull_request.author_association == 'OWNER' ||
github.event.pull_request.author_association == 'COLLABORATOR'
steps:
- uses: toshimaru/[email protected]
13 changes: 12 additions & 1 deletion .github/workflows/issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Linked Issue

on:
pull_request:
types: [opened, edited]
types: [opened, edited, ready_for_review]

env:
VALID_ISSUE_PREFIXES: "CNCT|DASH|PROT|INSIGHT|ENGINE|CS|DES|BIL|DEVX|SOLU|NEB"
Expand All @@ -22,6 +22,17 @@ jobs:
pull_number: context.issue.number
});
// Check if contributor is external
const isInternalContributor = ['MEMBER', 'OWNER', 'COLLABORATOR'].includes(
context.payload.pull_request.author_association
);
// Automatically pass for external contributors
if (!isInternalContributor) {
console.log('External contributor detected - automatically passing check');
return;
}
const body = pr.data.body || '';
const branchName = pr.data.head.ref;
const issueRegex = new RegExp(`(${process.env.VALID_ISSUE_PREFIXES})-\\d+`, 'i');
Expand Down

0 comments on commit dc1e07b

Please sign in to comment.