Skip to content

Commit

Permalink
- update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbahl committed Sep 10, 2024
1 parent de885f1 commit a56eaf3
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@ jobs:
uses: actions/github-script@v6
with:
script: |
const octokit = github.getOctokit(process.env.GITHUB_TOKEN);
const { data: membership } = await octokit.orgs.checkMembershipForUser({
org: 'wpengine',
username: context.payload.pull_request.user.login,
}).catch(err => {
return { data: { state: 'none' } };
const { Octokit } = require("@octokit/rest");
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
});
return { isMember: membership.state === 'active' };
const org = 'wpengine'; // replace with your GitHub org
const username = context.payload.pull_request.user.login;
try {
const { data: membership } = await octokit.orgs.getMembershipForUser({
org,
username,
});
return { isMember: membership.state === 'active' };
} catch (error) {
return { isMember: false }; // If not a member or error occurs, treat as not a member
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down

0 comments on commit a56eaf3

Please sign in to comment.