Skip to content

Add new Anime media types #152

Add new Anime media types

Add new Anime media types #152

Workflow file for this run

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@v4
with:
token: ${{ secrets.BOT }}
- name: Parse Comment
uses: actions/github-script@v7
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@v7
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"