Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

chore: GitHub upgrades and allow arguments #46

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,51 @@ jobs:
hello:
runs-on: ubuntu-latest
steps:
- uses: khan/pull-request-comment-trigger@master
- uses: shanegenschaw/pull-request-comment-trigger@master
id: check
with:
trigger: '#hello'
- run: 'echo Found it!'
trigger: "#hello"
- run: "echo Found it!"
if: steps.check.outputs.triggered == 'true'

eyes:
runs-on: ubuntu-latest
steps:
- uses: khan/pull-request-comment-trigger@master
- uses: shanegenschaw/pull-request-comment-trigger@master
id: check
with:
trigger: '#look'
trigger: "#look"
reaction: eyes
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- run: 'echo Found it!'
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- run: "echo Found it!"
if: steps.check.outputs.triggered == 'true'

rocket:
runs-on: ubuntu-latest
steps:
- uses: khan/pull-request-comment-trigger@master
- uses: shanegenschaw/pull-request-comment-trigger@master
id: check
with:
trigger: '#deploy'
trigger: "#deploy"
reaction: rocket
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- run: 'echo Found it!'
if: steps.check.outputs.triggered == 'true'
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- run: "echo Found it!"
if: steps.check.outputs.triggered == 'true'

arguments-rocket:
runs-on: ubuntu-latest
steps:
- uses: shanegenschaw/pull-request-comment-trigger@master
id: check
with:
trigger: "#deploy on ** environment"
reaction: rocket
allow_arguments: true
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- run: |
echo 'Found it!'
echo 'Deploy on ${{ fromJson(steps.check.outputs.arguments)[0] }}'
if: steps.check.outputs.triggered == 'true'
30 changes: 29 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Look for a "trigger word" in a pull-request description or comment, so that late

<!-- TODO release workflow-preprocessor This is most useful in tandem with [workflow-preprocessor], so that you don't have to be writing a ton of `if`s all down the line. -->

:warning: This is a fork of the [Khan/pull-request-comment-trigger](https://github.com/Khan/pull-request-comment-trigger) action ([marketplace](https://github.com/marketplace/actions/pull-request-comment-trigger)), with upgrades for deprecated GitHub Actions functionality:

- [2022-10-11-github-actions-deprecating-save-state-and-set-output-commands](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/)
- [2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12](https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/)

See the upstream pull request [`chore: GitHub upgrades` #46](https://github.com/Khan/pull-request-comment-trigger/pull/46) for more details.

## Example usage in a workflow

Your workflow needs to listen to the following events:
Expand All @@ -22,7 +29,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: khan/pull-request-comment-trigger@v1.1.0
- uses: shanegenschaw/pull-request-comment-trigger@v2.1.0
id: check
with:
trigger: '@deploy'
Expand All @@ -33,6 +40,25 @@ jobs:
if: steps.check.outputs.triggered == 'true'
```

You can either pass arguments in your comment, e.g. `@deploy dev`:

```
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: shanegenschaw/[email protected]
id: check
with:
trigger: '@deploy **'
reaction: rocket
allow_arguments: true
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- run: 'echo Found it! Deploy on ${{ fromJson(steps.check.outputs.arguments)[0] }}'
if: steps.check.outputs.triggered == 'true'
```

Reaction must be one of the reactions here: https://developer.github.com/v3/reactions/#reaction-types
And if you specify a reaction, you have to provide the `GITHUB_TOKEN` env vbl.

Expand All @@ -43,6 +69,7 @@ And if you specify a reaction, you have to provide the `GITHUB_TOKEN` env vbl.
| trigger | Yes | The string to look for in pull-request descriptions and comments. For example "#build/android". |
| prefix_only | No (default 'false') | If 'true', the trigger must match the start of the comment. |
| reaction | No (default '') | If set, the specified emoji "reaction" is put on the comment to indicate that the trigger was detected. For example, "rocket". |
| allow_arguments | No (default 'false') | If 'true', script looks for `**` markers that are considered as comment arguments. |


## Outputs
Expand All @@ -51,3 +78,4 @@ And if you specify a reaction, you have to provide the `GITHUB_TOKEN` env vbl.
| ------ | ----------- |
| triggered | 'true' or 'false' depending on if the trigger phrase was found. |
| comment_body | The comment body. |
| arguments | The comment arguments. |
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Pull Request Comment Trigger'
name: 'Pull Request Comment Trigger fork'
description: 'Look for a "trigger word" in a pull-request description or comment, so that later steps can know whether or not to run.'
inputs:
reaction:
Expand All @@ -12,14 +12,18 @@ inputs:
description: If 'true', the trigger must match the start of the comment.
required: false
default: "false"
allow_arguments:
description: If 'true', the trigger can have arguments. Can be passed via "**".
required: false
default: "false"
outputs:
triggered:
description: the string 'true' if the trigger was found, otherwise the string 'false'
comment_body:
description: The comment body.
runs:
using: 'node12'
using: 'node20'
main: 'dist/index.js'
branding:
icon: check-circle
color: red
color: red
Loading