© ZOZO Technologies, Inc.
github-scriptsで簡単GitHub API連携
github-script アクションはインプットに JavaScript が記述でき、
ワークフローで簡単に GitHub API を使った処理が追加できる
32
on:
issues:
types: [opened]
jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: Comment on an issue
uses: actions/
[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const commentBody = `Hi @${context.actor}! Thanks for the feedback! We'll
assign the issue to the content author to evaluate and update as appropriate.`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
Issueへのコメント例
Script シンタックスの中で既に API 認証済み
の octokit/rest.js のクライアントであるgithub
オブジェクトが利用可能
● gitHub-script: https://github.com/actions/github-script
● Octokit/rest.js: https://octokit.github.io/rest.js/