int128 / issues-action

Bulk operation of issues or pull requests, such as posting a comment, adding or removing labels, or updating issue body

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

issues-action ts

This is an action for the following operations to issues or pull requests:

  • Post a comment
  • Add label(s)
  • Remove label(s)
  • Update an issue body

Getting Started

Post comment

To post a comment to the current pull request,

    steps:
      - uses: int128/issues-action@v2
        with:
          context: true
          post-comment: |
            :white_check_mark: test passed

For example,

image

To post a comment to open pull requests,

    steps:
      - name: List open pull requests
        id: list-open
        uses: actions/github-script@v6
        with:
          result-encoding: string
          script: |
            const pulls = await github.paginate(github.rest.pulls.list, {
              owner: context.repo.owner,
              repo: context.repo.repo,
              state: 'open',
              sort: 'updated',
              direction: 'desc',
              per_page: 100,
            })
            core.info(`found ${pulls.length} pull request(s)`)
            return pulls.map((e) => e.number).join('\n')
      - uses: int128/issues-action@v2
        with:
          issue-numbers: ${{ steps.list-open.outputs.result }}
          post-comment: |
            :zzz: This pull request has been undeployed. Set the label to deploy again.

Add or remove label

To add and remove a label to the current pull request,

    steps:
      - uses: int128/issues-action@v2
        with:
          context: true
          add-labels: test-passed
          remove-labels: test-failed

For example,

image

Update body

To append a content into the body of current pull request,

    steps:
      - uses: int128/issues-action@v2
        with:
          context: true
          append-or-update-body: |
            ----
            :octocat: Tested in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

For example,

image

If the content already exists in the pull request, this action replaces it with the new one.

Specification

This action accepts the following inputs:

Name Default Description
context false Infer an issue or pull request(s) from the context
issue-numbers - List of issue(s) or pull request(s), in multiline string
add-labels - Label name(s) to add to issues or pull requests, in multiline string
remove-labels - Label name(s) to remove from issues or pull requests, in multiline string
post-comment - Comment to create into issues or pull requests
append-or-update-body - Update body of issues or pull requests
token github.token A token for GitHub API

If issue-numbers is not set, this action does nothing.

Infer the current pull request

If context is true, this action infers by the following rules:

  • On pull_request event, use the current pull request
  • On issue event, use the current issue
  • On other events, find pull request(s) associated with github.sha

To post a comment when a pull request is created, updated or merged into main branch:

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  comment:
    steps:
      - uses: int128/issues-action@v2
        with:
          context: true
          post-comment: |
            :x: something wrong

About

Bulk operation of issues or pull requests, such as posting a comment, adding or removing labels, or updating issue body

License:Apache License 2.0


Languages

Language:TypeScript 94.7%Language:JavaScript 5.3%