The following use cases describes how you can create a team in a GitHub® organization, invite an user to join the organization and the newly created team. For the last step in the Workflow, we will remove the team, leaving the organization as it was initially.
You will need a GitHub personal access token with the correct privileges (admin:org).
You will also need access to Boomerang Flow.
First, lets create the new Workflow by navigating to the Workflows page and clicking Create new Workflow. At the modal, choose to Start from scratch, fill in the details, and select Create.
You are taken to the Workflow Editor for this particular Workflow. In the tabbed menu, select the Parameters and define four Required parameters, named url - the GitHub® API endpoint, token - personal access token with the correct privileges (admin:org), emailAddress - the email address of the member that will get invited to the team and org - the name of the GitHub organization where the team is created. Provide the values specific to your case.
In the left panel of the Workflows tabbed page, expand the GitHub category and drag the following Tasks onto the canvas: Create Team in Organization, Invite User to Organization, Invite Member to Team, and Delete Team from Organization. After that, expand the Utilities category and drag the following two Tasks onto the canvas: Sleep and Json Path To Property. You can chain the Tasks, as shown in the following screenshot.
Edit each Task with the following parameters, using the pencil icon at the top of the Task.
For the Create Team in Organization Task, enter the following specifics.
Create Team
$(params.url)
$(params.token)
$(params.org)
Team name testing
closed
For the Json Path To Property Task, enter the following specifics.
Get team name
$(Task.Create Team.results.team)
$.name
createdTeamName
For the Invite User to Organization Task, enter the following specifics.
Invite User to Organization
$(Workflow.params.emailAddress)
For the Invite Member to Team Task, enter the following specifics.
Invite Member to Team
$(Task.Get team name.results.createdTeamName)
For the Sleep Task, enter the following specifics.
30000
.For the Delete Team from Organization Task, enter the following specifics.
Delete Team
$(Task.Get team name.results.createdTeamName)
Next, wire these Tasks together by dragging a line from Start to End, going through the configured Tasks. You need to change the status checks of the links to logic-success
.
To learn more about this, navigate to Getting to Know | Editor | Links in the Flow documentation.
The last step is to save the Workflow by selecting Create new version from the top-right corner.
To test your Workflow, you can run this manually from the Workflows page. Identify the newly created Workflow and select Run it. In the Workflow Parameters window, fill in the parameter values and select Run or Run and View.
Once the Workflow starts, you are redirected to the activity details, depicting the progress of the execution.
When the Workflow diagram shows the Sleep Task as running, let's open the Organization Teams GitHub UI page: https://github.ibm.com/orgs/test-Workflow/teams
. If you defined a different value for the org parameter, make sure you replace it in the URL when accessing the GitHub UI.
Coming back to the Flow Activity UI, the Workflow execution should have reach its end. Checking back the Teams GitHub UI page, you should not see the team in the organization.