-
-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (53 loc) · 1.92 KB
/
slash-command.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
51
52
53
54
55
56
57
58
name: Command Dispatch
on:
issue_comment:
types: [created]
permissions: read-all
jobs:
slash-command:
if: github.event.issue.pull_request && github.event.issue.user.login == 'FabrizioCafolla'
runs-on: ubuntu-22.04
steps:
- name: Get PR repo and ref
id: getref
uses: actions/github-script@v7
with:
github-token: ${{ secrets.ACTION_WORKFLOWS }}
script: |
const pr_number = "${{ github.event.issue.pull_request.url }}".split("/").slice(-1);
const pr = await github.rest.pulls.get({
owner: "italia-opensource",
repo: "italiaopensource.com",
pull_number: pr_number,
});
core.exportVariable('PR_NUMBER', pr.data.number);
core.exportVariable('PR_URL', pr.data.html_url);
core.exportVariable('USER', pr.data.user.login);
core.exportVariable('PR_REF', pr.data.head.ref);
core.exportVariable('PR_SHA', pr.data.head.sha);
- name: Slash Command Dispatch
id: scd
uses: peter-evans/slash-command-dispatch@v4
with:
token: ${{ secrets.ACTION_WORKFLOWS }}
permission: write
commands: |
deploy-website
deploy-infrastructure
static-args: |
pr_number=${{ env.PR_NUMBER }}
pr_url=${{ env.PR_URL }}
pr_ref=${{ env.PR_REF }}
pr_sha=${{ env.PR_SHA }}
user=${{ env.USER }}
comment_id=${{ github.event.comment.id }}
dispatch-type: repository
reactions: false
- name: Add error message to comment
if: steps.scd.outputs.error-message
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.ACTION_WORKFLOWS }}
comment-id: ${{ github.event.comment.id }}
body: |
> Error: ${{ steps.scd.outputs.error-message }}