forked from Azure/bicep
-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (46 loc) · 1.79 KB
/
slash-command-dispatch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Implements "slash commands" on PR comments
# see https://github.com/peter-evans/slash-command-dispatch
# and https://david.gardiner.net.au/2021/05/dependabot-nuget-lockfiles.html
# Listens for a comment on a pull request beginning with "/{command}" and dispatches that command
# E.g. commenting "/lockfiles" will dispatch the "lockfiles-command.yml" workflow
#
# Note: An "eyes" icon is added when the command has been seen, and a "rocket" icon when the command has been dispatched
name: Slash Command Dispatch
on:
issue_comment:
types: [created]
jobs:
slashCommandDispatch:
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
pull-requests: write
steps:
- name: Bot Details
id: bot-details
uses: raven-actions/bot-details@v1
# Obtain the name of the branch that is linked to the pull request for the triggering comment.
- uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
- name: Dump comment context
env:
COMMENT_CONTEXT: ${{ toJson(steps.comment-branch.outputs) }}
run: echo "$COMMENT_CONTEXT"
- name: Dispatch slash command
uses: peter-evans/slash-command-dispatch@v4
id: slash-command
with:
token: ${{ secrets.GITHUB_TOKEN }}
commands: |
lockfiles
permission: write
issue-type: pull-request
# We want the secondary workflow to run against the pull request branch (not the default branch)
dispatch-type: workflow
static-args: ref=${{ steps.comment-branch.outputs.head_ref }}
- name: Dump slash context
env:
SLASH_CONTEXT: ${{ toJson(steps.slash-command) }}
run: echo "$SLASH_CONTEXT"