From 7a3338113fd7b4e28a28a27f90590f88c6bd5b7e Mon Sep 17 00:00:00 2001 From: Hidetake Iwata Date: Sat, 23 Nov 2024 16:17:47 +0900 Subject: [PATCH] Add `starts-with`, `ends-with` to outputs (#1128) --- README.md | 44 ++++++++++++++++++++++---------------------- action.yaml | 18 +++++++++++++----- src/main.ts | 2 ++ 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 6ac6f0e9..c017ee7f 100644 --- a/README.md +++ b/README.md @@ -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: @@ -14,7 +13,7 @@ on: pull_request: jobs: - hide-comment: + test: steps: - uses: int128/hide-comment-action@v1 ``` @@ -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. @@ -45,22 +43,17 @@ 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: | - + ends-with: - uses: int128/comment-action@v1 with: - run: yarn test - post-on-failure: | - ## :x: Test failure - ``` - ${run.output} - ``` - + post: | + :wave: Hello World! + ${{ steps.hide-comment.outputs.ends-with }} ``` - ## Specification This action works on pull request event only. @@ -68,11 +61,18 @@ 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` | diff --git a/action.yaml b/action.yaml index 53457a6a..c0adb229 100644 --- a/action.yaml +++ b/action.yaml @@ -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) @@ -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' diff --git a/src/main.ts b/src/main.ts index 554a7755..d1918717 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,6 +10,8 @@ const main = async (): Promise => { 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 => {