-
-
Notifications
You must be signed in to change notification settings - Fork 4
56 lines (51 loc) · 1.76 KB
/
mal.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
name: MyAnimeList API Request
on:
issue_comment:
types: [created]
jobs:
mal:
name: MyAnimeList API Request
runs-on: ubuntu-latest
if: contains('OWNER, MEMBER, COLLABORATOR', github.event.comment.author_association) && contains(github.event.comment.body, 'mal ')
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.BOT }}
- name: Parse Comment
uses: actions/github-script@v6
env:
comment: ${{ github.event.comment.body }}
with:
github-token: ${{ secrets.BOT }}
script: |
const comment = process.env.comment.split(' ');
if(comment[0] == "mal")
core.exportVariable("url", comment[1]);
- name: cURL
if: env.url
env:
url: ${{ env.url }}
token: ${{ secrets.MAL_CLIENT }}
run: |
out=$(curl https://api.myanimelist.net/v2/$url -X GET -H "X-MAL-CLIENT-ID: $token")
echo "out=$out" >> "$GITHUB_ENV"
- name: Format JSON
uses: actions/github-script@v6
if: env.out
env:
url: ${{ env.url }}
out: ${{ env.out }}
with:
github-token: ${{ secrets.BOT }}
script: |
core.exportVariable("comment", "`https://api.myanimelist.net/v2/" + process.env.url + "`\n\n" + "```json\n" + JSON.stringify(JSON.parse(process.env.out), null, 4) + "\n```");
- name: Print Response
if: env.comment
env:
GITHUB_TOKEN: ${{ secrets.BOT }}
comment: ${{ env.comment }}
number: ${{ github.event.issue.number }}
issue: ${{ github.event.issue && 'issue' || 'pr' }}
run: |
gh $issue comment $number -b "$comment"