-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b208ec0
commit 8e77d52
Showing
1 changed file
with
15 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,56 +8,29 @@ jobs: | |
check_author_team_membership: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get teams | ||
id: get_teams | ||
uses: octokit/[email protected] | ||
with: | ||
route: GET /orgs/:org/teams | ||
org: ${{ github.event.organization.login }} | ||
headers: | ||
authorization: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check if author is a member of opsTrack team | ||
id: check_author_membership | ||
- name: Check if author is opsTrack member | ||
id: check_author | ||
run: | | ||
const teams = ${{fromJson(steps.get_teams.outputs.data)}}; | ||
const opsTrackTeam = teams.find(team => team.slug === 'opsTrack'); | ||
const teamMembers = await github.rest.teams.listMembersInOrg({ | ||
org: context.payload.organization.login, | ||
team_slug: opsTrackTeam.slug, | ||
headers: { | ||
authorization: `token ${{ secrets.GITHUB_TOKEN }}` | ||
} | ||
}); | ||
const author = context.payload.sender.login; | ||
const isMember = teamMembers.some(member => member.login === author); | ||
if (isMember) { | ||
console.log('Author is a member of opsTrack team'); | ||
core.setOutput('opsTrackMember', 'true'); | ||
} else { | ||
console.log('Author is not a member of opsTrack team'); | ||
core.setOutput('opsTrackMember', 'false'); | ||
} | ||
response=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/orgs/${{ github.event.organization.login }}/teams/opsTrack/members") | ||
if echo "$response" | grep -q "\"login\": \"${{ github.event.pull_request.user.login }}\""; then | ||
echo "::set-output name=isMember::true" | ||
else | ||
echo "::set-output name=isMember::false" | ||
fi | ||
label_pr_needing_reviews: | ||
needs: check_author_team_membership | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check if opsTrack member | ||
run: echo "Author is opsTrack member: ${{ needs.check_author_team_membership.outputs.opsTrackMember }}" | ||
id: opsTrack_member_check | ||
run: echo "Author is opsTrack member:${{ needs.check_author_team_membership.outputs.isMember }}" | ||
|
||
- name: Add label if opsTrack member | ||
if: steps.opsTrack_member_check.outputs.opsTrackMember == 'true' | ||
uses: actions/github-script@v5 | ||
if: steps.check_author_team_membership.outputs.isMember == 'true' | ||
uses: dessant/label-actions@v4 | ||
with: | ||
script: | | ||
github.issues.addLabels({ | ||
owner: context.payload.repository.owner.login, | ||
repo: context.payload.repository.name, | ||
issue_number: context.payload.pull_request.number, | ||
labels: ['codeowner reviews required'] | ||
}); | ||
script-output: | | ||
{ token: '${{ secrets.GITHUB_TOKEN }}' } | ||
action: add | ||
labels: codeowner reviews required | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} |