Skip to content

Latest commit

 

History

History
67 lines (51 loc) · 5.04 KB

README.md

File metadata and controls

67 lines (51 loc) · 5.04 KB

Find Last Issue

GitHub Action to find and output the number of last updated issue that has given labels and state.

Action inputs

Name Description Default
repository The target GitHub owner and name separated by slash. For example: micalevisk/last-issue-action. github.repository
token A repo scoped Personal Access Token with at least issues: read permissions. github.token (generated automatically by GitHub)
* labels Comma or newline-separated list of labels that the issue must have
state Issue state to filter by. Can be one of the following strings:
  • "open": if you want to look up for open issues only
  • "closed": if you want to look up for closed issues only
  • "all": if you want to look up for open or closed ones
"open"

Action outputs

Name Description
issue-number The number of the issue found, otherwise empty.
has-found Response status. Will be true if some issue was found, otherwise false.
is-closed Will be true if the issue found is closed, otherwise false. Then you can use issue-number to open it again with another GitHub Action.

Note that none of the above will be defined if any error occurs (eg: fetching a repository that doesn't exists).

If has-found is true, then issue-number and is-closed will be defined as well.

Example usage

You can use this action along with create-issue-from-file action, like:

# ...

- name: Find the last open report issue
  id: last-issue
  uses: micalevisk/last-issue-action@v2
  with:
    state: open
    # Find the last updated open issue that has these labels:
    labels: |
      report
      automated issue

- name: Update last updated report issue
  if: ${{ steps.last-issue.outputs.has-found == 'true' }}
  uses: peter-evans/create-issue-from-file@v4
  with:
    title: Foo
    content-filepath: README.md
    # Update an existing issue if one was found (issue-number),
    # otherwise an empty value creates a new issue:
    issue-number: ${{ steps.last-issue.outputs.issue-number }}
    # Add a label(s) that `last-issue` can use to find this issue,
    # and any other relevant labels for the issue itself:
    labels: |
      report
      automated issue