43 lines (39 loc) · 1.48 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
# a workflow that runs when a user enters a pull request comment
# if the user enters "/cypress" we trigger the workflow "slash-command-cypress"
name: Slash Command Dispatch
on:
issue_comment:
types: [created]
jobs:
slash_command_dispatch:
runs-on: ubuntu-latest
steps:
- name: Print event 🖨️
run: |
echo off
echo '${{ toJson(github.event) }}'
# we only know the pull request number, like 12, 20, etc
# but to trigger the workflow we need the branch name
# use personal token to be able to query the branch by PR number
# https://github.com/bahmutov/get-branch-name-by-pr
- name: Find the PR branch name 🔎
uses: bahmutov/get-branch-name-by-pr@v1
id: pr
with:
repo-token: ${{ secrets.PERSONAL_TOKEN }}
pr-id: ${{ github.event.issue.number }}
- name: Slash Command Dispatch
# https://github.com/peter-evans/slash-command-dispatch
uses: peter-evans/slash-command-dispatch@v3
with:
# use personal token to be able to trigger more workflows
token: ${{ secrets.PERSONAL_TOKEN }}
# the personal token to post the comment emoji
reaction-token: ${{ secrets.PERSONAL_TOKEN }}
permission: none
static-args: |
repository=${{ github.repository }}
comment-id=${{ github.event.comment.id }}
ref=${{ steps.pr.outputs.branch }}
commands: |
cypress