Skip to content

Commit

Permalink
feat: build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 8, 2022
1 parent 18b4e4f commit 044e1cb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 35 deletions.
59 changes: 32 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
# Find Last Issue ![](https://img.badgesize.io/micalevisk/last-issue-action/gh-actions/bundle/index.js.svg?style=flat&color=purple&compression=brotli)
<div align="center">

# Find Last Issue

![](https://img.badgesize.io/micalevisk/last-issue-action/gh-actions/bundle/index.js.svg?style=flat&color=purple&compression=brotli)

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

</div>

### Action inputs

| Name | Description | Default |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| **\*** `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: <ul><li> <code>"open"</code>: if you want to look up for open issues only </li><li> <code>"closed"</code>: if you want to look up for closed issues only </li><li> <code>"all"</code>: if you want to look up for open or closed ones </li></ul> | `"open"` |
| Name | Description | Default |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| `repository` | The target GitHub owner and name separated by slash. For example: `micalevisk/last-issue-action`. | `github.repository` |
| `token` | A [`repo`][settings-create-scoped-token] scoped [Personal Access Token][docs-token-pat] with at least [`issues: read` permissions][docs-token-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: <ul><li> <code>"open"</code>: if you want to look up for open issues only </li><li> <code>"closed"</code>: if you want to look up for closed issues only </li><li> <code>"all"</code>: if you want to look up for open or closed ones </li></ul> | `"open"` |

[docs-token-pat]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
[docs-token-permissions]: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
[settings-create-scoped-token]: https://github.com/settings/tokens/new?scopes=repo:status,repo_deployment,public_repo

### Action outputs

| Name | Description |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `issue_number` | The number of the issue found, if any. |
| `has_found` | Response status. Will be `true` if some issue was found. `false` otherwise. |
| `is_closed` | Will be `true` if the found issue is closed. The you can use `issue_number` to open it again with [another GitHub Action](https://github.com/marketplace/actions). |
| 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](https://github.com/marketplace/actions). |

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.

### Environment variables

| Name | Description | Default |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
| `GITHUB_TOKEN` | `GITHUB_TOKEN` or a [`repo`](https://github.com/settings/tokens/new?scopes=repo:status,repo_deployment,public_repo) scoped [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) | `GITHUB_TOKEN` secret created by GitHub |
If `has-found` is `true`, then `issue-number` and `is-closed` will be defined as well.

## Example usage

Expand All @@ -35,27 +41,26 @@ You can use this action along with [create-issue-from-file](https://github.com/p
# ...

- name: Find the last open report issue
id: last_issue
uses: micalevisk/last-issue-action@v1.2
id: last-issue
uses: micalevisk/last-issue-action@v2
with:
state: open
## The issue must have the following labels
# Find the last updated open issue that has these labels:
labels: |
report
automated issue
env:
## Optional since it uses the `GITHUB_TOKEN` created by GitHub by default
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: echo ${{ steps.last_issue.outputs.issue_number }}
- name: Update last updated report issue
if: ${{ steps.last_issue.outputs.has_found == 'true' }}
if: ${{ steps.last-issue.outputs.has-found == 'true' }}
uses: peter-evans/create-issue-from-file@v4
with:
title: Foo
content-filepath: README.md
issue-number: ${{ steps.last_issue.outputs.issue_number }}
# 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
Expand Down
18 changes: 12 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@ name: 'Find Last Issue'
author: 'Micael Levi L. C.'
description: 'GitHub Action to find and export the number of last updated issue whithin some repository that has given labels.'
inputs:
repository:
description: 'The target GitHub owner and name separated by slash. For example: `micalevisk/last-issue-action`.'
default: ${{ github.repository }}
token:
description: 'The GitHub token providing at least `issues: read` authorization to the repository.'
default: ${{ github.token }}
labels:
description: 'Comma-separated label names that the issue must have.'
required: true
state:
description: 'Issue state to filter by. Can be `"open"`, `"closed"` or `"all"`'
required: false
outputs:
issue_number:
description: 'The number of the issue found, if any.'
has_found:
description: 'Response status. Will be `true` if some issue was found. `false` otherwise.'
is_closed:
description: 'Will be `true` if the found issue is closed. `false` otherwise.'
issue-number:
description: 'The number of the issue found, otherwise empty.'
has-found:
description: 'Response status. Will be `true` if some issue was found, otherwise `false`.'
is-closed:
description: 'Will be `true` if the issue found is closed, otherwise `false`.'
runs:
using: 'node16'
main: 'bundle/index.js'
Expand Down
4 changes: 2 additions & 2 deletions bundle/index.js

Large diffs are not rendered by default.

0 comments on commit 044e1cb

Please sign in to comment.