To update the issue status.

git:issue-update

Close or open an issue and modify the issue labels.

# Applicable Events

所有事件

# Workflow

Check if the issue exists -> Check if it meets the when condition (optional) -> Check if it meets the lint condition (optional) -> Update the issue status or labels

# Getting the Issue ID

  • If the fromText parameter is provided, extract it from fromText. For example, branch.delete requires fromText (the branch has been deleted, so it cannot be obtained from the context).
  • If the fromText parameter is not provided, extract it from the context.
    • push event: Extract it from the commit messages of all commits in the current push.
    • Pull request events: Extract it from the commit messages of all commits in the pull request.
    • Other events: Extract it from the commit message of the latest commit.

The following two formats are supported:

  • #issueID: Refers to an issue in the current repository. For example, #123 refers to issue ID 123 in the current repository.
  • groupName/repoName#issueID: Refers to an issue in a different repository. For example, test/test#123 refers to issue ID 123 in the test/test repository.

Note that there should be a space before #123 or test/test#123.

# How to Include the Issue ID in Commit Messages

When committing code, you can include the associated issue ID in the commit message. The built-in tasks can automatically extract the associated issue ID to update the issue labels and status.

It is recommended to include the issue ID in the body of the commit message. Here are two ways to do it from the command line:

  • Method 1:

Use shift + enter to create a new line. It is recommended to add an empty line between the title and the body.

git commit -m "fix(CI): Fixed an error


cnb/feedback#123"
  • Method 2:

The following commit method will create two new lines between the title and the body.

git commit -m "fix(CI): Fixed an error" -m "cnb/feedback#123"

# Parameters

# fromText

  • type: String
  • required: false

Parse 'issue id' from the given text.

When not specified, automatically parse from the commit history in the context.

You can specify a text containing a reference to the 'issue id' to declare the target of the operation, for example: ${LATEST_CHANGE_LOG}.

# state

For the 'state' attribute, when set to 'close', it can close the issue.

# label

Description of operations on label.

# when

Filter conditions. Multiple conditions have an 'or' relationship. When it is empty, it indicates that the operation applies to all issues.

# lint

To check if an issue meets the conditions, and throw an exception if it doesn't, the conditions have an 'or' relationship between them. When the conditions are empty, it means no checks are performed.

# defaultColor

  • type: String
  • required: false

The default color for added labels is only effective when the 'label.add' parameter is passed.

Schema Definition

# IssueStateMap

  • Enum<String>

open | close

# IssueUpdateLabel

add

  • type: Array<String> | String
  • required: false

"The list of labels to be added. If a label does not exist, it will be automatically created."

remove

  • type: Array<String> | String
  • required: false

The list of labels to be removed.

# IssueUpdateStatus

label

  • type: Array<String> | String
  • required: false

"Labels. Multiple values have an 'or' relationship."

# Output Results

{
    issues // list of issues
}

# Configuration Example

  • Update Labels after Merging into Main
main:
  push:
    - stages:
        - name: update issue
          type: git:issue-update
          options:
            # Remove the "In Progress" label and add the "Pre-release" label
            label:
              add: Pre-release
              remove: In Progress
            # Only perform the label operation if the issue has the "feature" or "bug" label
            when:
              label:
                - feature
                - bug
  • Close Issue and Update Labels on tag_push
$:
  tag_push:
    - stages:
        - name: perform release
          script: echo "Replace this task with your actual release process"
        # Perform issue update after the release process
        - name: update issue
          type: git:issue-update
          options:
            # Close the issue
            state: close
            # Remove the "Pre-release" label and add the "Released" label
            label:
              add: Released
              remove: Pre-release
            # Only perform the operation if the issue has the "feature" or "bug" label
            when:
              label:
                - feature
                - bug
  • Add Labels Based on Changelog
$:
  tag_push:
    - stages:
        - name: changelog
          image: cnbcool/changelog
          exports:
            latestChangeLog: LATEST_CHANGE_LOG
        - name: update issue
          type: git:issue-update
          options:
            fromText: ${LATEST_CHANGE_LOG}
            label:
              add: Requirement Accepted
            when:
              label: feature