About IssueOps
In GitHub, a pull request (PR) can be interacted with in a lot of the same ways as an issue. For example, the List repository issues REST API will return both issues and PRs for a repository.This means that many of the features of an issue are applicable to a PR. However, PRs have some extra functionality that can also be used in an IssueOps workflow. Depending on the use-case, you might want to select one over the other. For example, if you want to use the review and approval functionality for changes to repository contents, you'll need to use a PR. If you want to use the issue forms feature, you'll need to use an issue.For more information on their structure and usage in IssueOps, see Issues and PRs.Think of IssueOps as a state diagram . An issue is the object that changes state in response to specific events. As the object changes state, certain actions may be performed as part of the transition (provided any guard conditions are met). Once an end state is reached, the issue is considered complete and can be closed.State Diagrams
The following sections contain definitions and examples of common terms used in state diagrams. These terms are used throughout this documentation.Action
An atomic task that is performed when a transition is taken.@mona
@mona has invited you to collaborate
Event
An external occurrence that triggers a state change.@mona
@octocat self-assigned this
Guard
A condition that is evaluated when a trigger event occurs. A transition is taken only if all associated guard conditions are met.State
A point in an object's lifecycle that satisfies certain condition(s).OpenTransition
A link between two states that, when traversed by an object, will cause certain action(s) to be performed.IssueOps workflow
In general, an IssueOps workflow will follow the same basic pattern:- A user opens an issue and provides information about a request
- The issue is validated to ensure it contains the required information
- (Optional) Approval is requested from an authorized user or team
- The request is processed and the issue is closed
Example: GitHub team membership
User Story: As a developer, I should be able to request membership to various teams and, if approved by administrators, be granted membership.Suppose you are an admin of an organization and would like to reduce the overhead of managing team membership. You can use IssueOps to build an automated membership request and approval process.We can assume the current, manual workflow looks something like this when rendered as a state diagram.Nodes
In state diagram format, nodes represent the state of an object (the membership request), while transitions represent actions that are taken as the object changes state.
Example State Diagram
Event triggers
In the membership request workflow, there are several events that trigger a change in the request state:- A user submits a request
- An admin approves a request
- An admin denies a request
- A user is added to a team
- A user is notified
Issues
Events related to issues seem like a good fit for IssueOps! Issues are the entrypoint to the worflow. In particular, the issue beingopened. You can think of this as someone coming to you and sayingCan you add me to this team? Until this event occurs, there's nothing to do!However, this is not the only issue event that can be used in a workflow. The following table lists other issue events and example use-cases.Event | Example |
---|---|
opened | Start a request workflow |
edited | Re-validate a modified request |
deleted | Cancel in-flight tasks for a request |
transferred | Assign ownership of a request to a different team |
pinned | Upgrade the severity/urgency of a request |
unpinned | Downgrade the severity/urgency of a request |
closed | End a request workflow |
reopened | Restart a request workflow |
assigned | Ping the assignee in Slack |
unassigned | Ping the previous assignee in Slack |
labeled | Track the current state of a request |
unlabeled | Track the current state of a request |
locked | See locking conversations |
unlocked | See locking conversations |
milestoned | Track requests by type to compare to team goals |
demilestoned | Track requests by type to compare to team goals |
Permissions
Access to delete issues should be carefully controlled. If you delete an issue, you will lose all of the information associated with it, including comments and attachments. You will also lose this request in the history of the repository.
Issue Comments
After an issue is opened, other events must take place that change the state and drive it through the workflow. In the membership request workflow, for example, commenting on an issue is a great way to handle state changes such as an administrator approving or denying the request.Approvals
A core difference between issues and PRs is that issues do not have a built-in approval process. However, this can be implemented using issue comments. For more information, see Approvals.
issue_comment
events that can trigger workflows:created
edited
deleted
issue_comment
context can provide us with information to decide what actions to take, if any. In our team membership workflow, we can get the user that created the comment using the github.event.comment.user.login
property. We can then use this to determine if the user is authorized to approve the request.Labels
Labels are a great way to track the state of a request. You can think of these as the nodes in a state diagram, while the transitions are the actions that are taken as the request changes state. You can also use labels to classify the types of requests when your repository supports more than one IssueOps workflow. For example, in the membership request workflow, you might have the following labels:Label | Description |
---|---|
team-membership-request | The type of request |
submitted | Requests that have been submitted and are pending review |
approved
, denied
, or closed
states? These states don't have any transitions that do not lead to the issue being closed. In other words, once a request is approved or denied, the issue will always reach the closed
state, regardless of whether it was approved or denied. If this workflow had more steps, such as requiring multiple approvals, additional states would need to be tracked.As with issue_comment
events, there are only three label
events available:created
edited
deleted
issue => labeled
event instead.Label Permissions
Anyone with access to open issues can also change labels! Labels are good for state tracking, but should not be used to determine if a request is valid! For more information, see the Validate step.