Skip to content

Update main.yml

Update main.yml #10

Workflow file for this run

name: Pull Request Review Labeler
on:
pull_request:
types: [opened]
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 }}

Check failure on line 18 in .github/workflows/main.yml

View workflow run for this annotation

GitHub Actions / Pull Request Review Labeler

Invalid workflow file

The workflow is not valid. .github/workflows/main.yml (Line: 18, Col: 13): A mapping was not expected
- name: Check if author is a member of opsTrack team
id: check_author_membership
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');
}
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
- name: Add label if opsTrack member
if: steps.opsTrack_member_check.outputs.opsTrackMember == 'true'
uses: actions/github-script@v5
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 }}' }