Run workflows with comment commands
Check out the Example Workflow.
on: issue_comment
name: Example
jobs:
parse-comment:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request }}
outputs:
command: ${{ steps.parse-comment.outputs.command }}
steps:
- uses: drewwyatt/comment-pipeline@v1
id: parse-comment
with:
comment: ${{ toJSON(github.event.comment) }}
commands: |
/format
/rebase
github-token: ${{ secrets.GITHUB_TOKEN }}
format:
runs-on: ubuntu-latest
needs: [parse-comment]
if: ${{ needs.parse-comment.outputs.command == '/format' }}
steps:
- run: echo 'formatting...'
rebase:
runs-on: ubuntu-latest
needs: [parse-comment]
if: ${{ needs.read-comment.outputs.command == '/rebase' }}
steps:
- run: echo 'rebasing...'
Newline delimited list of commands that should trigger workflows.
e.g.
# just one
commands: build
# more than one
# (the slashes are not required that is totally up to your preference)
commands: |
/format
/rebase
If you passed /format
and /rebase
like above, the following comments would all trigger this action:
- "/format"
- "/format this please"
- "/rebase 🔥"
these would ✖️ not ✖️
- "rebase"
- "please /format this PR"
The comment object (usually github.event.comment
)
you probably always want to do exactly what you see in the example workflow.
comment: ${{ toJSON(github.event.comment) }}
Almost always should be ${{ secrets.GITHUB_TOKEN }}
Emoji reaction used to acknowledge comment.
Possible options:
+1
-1
laugh
confused
heart
hooray
rocket
eyes
The matched command (from inputs.commands
) - this will be an empty if there is no match.
This is most commonly used to determine if a job or step should run. e.g.
In the example workflow, if one left a comment "/format this please", outputs.command
would be "/format" (because that is the exact command input match).
jobs:
parse-comment:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request }}
outputs:
command: ${{ steps.parse-comment.outputs.command }}
steps:
- uses: actions/checkout@v2
- uses: ./
id: parse-comment
with:
comment: ${{ toJSON(github.event.comment) }}
commands: |
/format
/rebase
github-token: ${{ secrets.GITHUB_TOKEN }}
format:
runs-on: ubuntu-latest
needs: [parse-comment]
if: ${{ needs.parse-comment.outputs.command == '/format' }} # <------ SEE HERE
steps:
- run: echo 'formatting...'
This may be useful if you would like to specify additional information other than the command. You can see some examples of args in the tests, like:
Given the comment "/format this please" (using previous config examples above), outputs.arguments
would be "this please".
Given a config where inputs.commands
includes deploy
, and a comment "deploy:stage", outputs.arguments
would be ":stage".
The entire comment body (if a command match was found).