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
name: Add new issues to PatternFly Extensions project | |
on: | |
issues: | |
types: | |
- opened | |
jobs: | |
add-to-project: | |
name: Add issue to project | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
with: | |
project-url: https://github.com/orgs/patternfly/projects/7 | |
github-token: ${{ secrets.GH_PROJECTS }} | |
label-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if the author is on the team | |
id: check_team_membership | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
try { | |
const username = context.payload.issue.user.login; | |
console.log(`Checking membership for user: ${username}`); | |
// Call GitHub API to check if the user is a member of the team | |
const membership = await github.teams.getMembershipForUserInOrg({ | |
org: 'patternfly', | |
team_slug: 'frequent-flyers', | |
username: username | |
}); | |
console.log(`Membership state: ${membership.data.state}`); | |
// Return the result as an output | |
return membership.data.state === 'active' ? { is_team_member: 'true' } : { is_team_member: 'false' }; | |
} catch (error) { | |
console.error(`Error checking team membership: ${error.message}`); | |
return { is_team_member: 'false' }; // Set false if there's any error | |
} | |
- name: Add label if user is a team member | |
if: steps.check_team_membership.outputs.is_team_member == 'true' | |
run: | | |
curl -X POST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels \ | |
-d '{"labels":["Team Member"]}' |