Skip to content

Commit

Permalink
Add starts-with, ends-with to outputs (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
int128 authored Nov 23, 2024
1 parent b4b573d commit 7a33381
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ This is an action to hide (minimize) comments in a pull request.

![screenshot](https://user-images.githubusercontent.com/321266/128599297-0edb5a92-7c83-42c7-9f8a-8946b4049ed3.png)


## Getting Started

To hide comments when a pull request is created or updated:
Expand All @@ -14,7 +13,7 @@ on:
pull_request:

jobs:
hide-comment:
test:
steps:
- uses: int128/hide-comment-action@v1
```
Expand All @@ -34,7 +33,6 @@ This action hides comment(s) which matches to **any** condition, i.e., evaluated

If no condition is given, this action hides comment(s) created by the user of GitHub token.


### Example: using `ends-with` condition

When you post a comment, it would be nice to add some marker so that you can hide it in the next build.
Expand All @@ -45,34 +43,36 @@ Here is an example workflow to hide the old comments before test.
jobs:
test:
steps:
- uses: int128/hide-comment-action@v1
- id: hide-comment
uses: int128/hide-comment-action@v1
with:
ends-with: |
<!-- test-notification -->
ends-with: <!-- test-notification -->
- uses: int128/comment-action@v1
with:
run: yarn test
post-on-failure: |
## :x: Test failure
```
${run.output}
```
<!-- test-notification -->
post: |
:wave: Hello World!
${{ steps.hide-comment.outputs.ends-with }}
```


## Specification

This action works on pull request event only.
It ignores other events.

### Inputs

| Name | Default | Description
|------|----------|-------------
| `authors` | - | Multi-line string of author condition
| `starts-with` | - | Multi-line string of starts-with condition
| `ends-with` | - | Multi-line string of ends-with condition
| `contains` | - | Multi-line string of contains condition
| `issue-number` | - | Number of an issue or pull request on which to hide comment(s)
| `token` | `${{ github.token }}` | GitHub token to post a comment
| Name | Default | Description |
| -------------- | --------------------- | -------------------------------------------------------------- |
| `authors` | - | Author condition (multi-line string) |
| `starts-with` | - | Starts-with condition (multi-line string) |
| `ends-with` | - | Ends-with condition (multi-line string) |
| `contains` | - | Contains condition (multi-line string) |
| `issue-number` | - | Number of an issue or pull request on which to hide comment(s) |
| `token` | `${{ github.token }}` | GitHub token to post a comment |

### Outputs

| Name | Description |
| ------------- | --------------------------- |
| `starts-with` | Same as input `starts-with` |
| `ends-with` | Same as input `ends-with` |
18 changes: 13 additions & 5 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: hide-comment
description: hide comment(s) in a pull request
description: Hide comment(s) of a pull request or issue

inputs:
authors:
description: multi-line string of author condition
description: Author condition (multi-line string)
required: false
starts-with:
description: multi-line string of starts-with condition
description: Starts-with condition (multi-line string)
required: false
ends-with:
description: multi-line string of ends-with condition
description: Ends-with condition (multi-line string)
required: false
contains:
description: multi-line string of contains condition
description: Contains condition (multi-line string)
required: false
issue-number:
description: Number of an issue or pull request on which to hide comment(s)
Expand All @@ -20,6 +21,13 @@ inputs:
description: GitHub token to post a comment
required: true
default: ${{ github.token }}

outputs:
starts-with:
description: Same as inputs.starts-with
ends-with:
description: Same as inputs.ends-with

runs:
using: 'node20'
main: 'dist/index.js'
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const main = async (): Promise<void> => {
issueNumber: issueNumber(core.getInput('issue-number')),
token: core.getInput('token', { required: true }),
})
core.setOutput('starts-with', core.getInput('starts-with'))
core.setOutput('ends-with', core.getInput('ends-with'))
}

const issueNumber = (s: string): number | undefined => {
Expand Down

0 comments on commit 7a33381

Please sign in to comment.