{"id":3217,"date":"2025-12-12T15:31:16","date_gmt":"2025-12-12T06:31:16","guid":{"rendered":"https:\/\/www.agile-software.site\/?p=3217"},"modified":"2025-12-18T09:34:10","modified_gmt":"2025-12-18T00:34:10","slug":"%f0%9f%a4%96-github-actions%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b-github_token-%e3%81%ae%e5%bd%b9%e5%89%b2","status":"publish","type":"post","link":"https:\/\/agile-software.net\/?p=3217","title":{"rendered":"&#x1f916; GitHub Actions\u306b\u304a\u3051\u308b GITHUB_TOKEN \u306e\u5f79\u5272"},"content":{"rendered":"\n<p><code>GITHUB_TOKEN<\/code> \u306f\u3001GitHub Actions\u306e\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u304c\u5b9f\u884c\u3055\u308c\u308b\u305f\u3073\u306b<strong>\u81ea\u52d5\u7684\u306b\u751f\u6210\u3055\u308c\u308b\u4e00\u6642\u7684\u306a\u8a8d\u8a3c\u30c8\u30fc\u30af\u30f3<\/strong>\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u306f\u3001\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u5185\u3067\u5b9f\u884c\u3055\u308c\u308b\u30a2\u30af\u30b7\u30e7\u30f3\u3084\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u3001GitHub Actions<strong>\u81ea\u8eab\u306b\u4ee3\u308f\u3063\u3066<\/strong>GitHub API\u3092\u901a\u3058\u3066\u64cd\u4f5c\uff08Issue\u306e\u4f5c\u6210\u3001\u30b3\u30e1\u30f3\u30c8\u306e\u6295\u7a3f\u3001\u30b3\u30fc\u30c9\u306e\u30c1\u30a7\u30c3\u30af\u30a2\u30a6\u30c8\u306a\u3069\uff09\u3092\u884c\u3046\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f4cc; \u57fa\u672c\u7684\u306a\u7279\u5fb4<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u81ea\u52d5\u751f\u6210:<\/strong> \u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u306e\u958b\u59cb\u6642\u306bGitHub\u306b\u3088\u3063\u3066\u81ea\u52d5\u3067\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u6709\u52b9\u671f\u9650:<\/strong> \u30b8\u30e7\u30d6\u304c\u5b8c\u4e86\u3059\u308b\u304b\u3001\u6700\u5927\u3067\u5b9f\u884c\u6642\u9593\u304c\u7d42\u4e86\u3059\u308b\u3068\u3001<strong>\u81ea\u52d5\u7684\u306b\u671f\u9650\u5207\u308c<\/strong>\u3068\u306a\u308a\u7121\u52b9\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n\n\n\n<li><strong>\u30a2\u30af\u30bb\u30b9\u65b9\u6cd5:<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>secrets<\/code> \u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092\u901a\u3058\u3066\u3001<code>${{ secrets.GITHUB_TOKEN }}<\/code> \u3068\u3044\u3046\u6a19\u6e96\u69cb\u6587\u3067\u53c2\u7167\u3067\u304d\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u30a2\u30af\u30b7\u30e7\u30f3\u306b\u306f\u3001\u660e\u793a\u7684\u306b\u6e21\u3055\u308c\u306a\u304f\u3066\u3082 <code>github.token<\/code> \u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u7d4c\u7531\u3067\u30a2\u30af\u30bb\u30b9\u6a29\u304c\u3042\u308a\u307e\u3059\uff08\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u306e\u7406\u7531\u304b\u3089\u3001<strong>\u660e\u793a\u7684\u306b\u6e21\u3059\u304b\u6a29\u9650\u3092\u5236\u9650\u3059\u308b\u3053\u3068\u304c\u63a8\u5968<\/strong>\u3055\u308c\u307e\u3059\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f6e0;&#xfe0f; <code>GITHUB_TOKEN<\/code> \u306e\u4e3b\u306a\u4f7f\u7528\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f8b 1: \u30a2\u30af\u30b7\u30e7\u30f3\u3084CLI\u3078\u306e\u5165\u529b\u3068\u3057\u3066\u6e21\u3059<\/h3>\n\n\n\n<p>GitHub CLI (Command Line Interface) \u306a\u3069\u3001\u5916\u90e8\u306e\u30c4\u30fc\u30eb\u3084\u72ec\u81ea\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u3001\u8a8d\u8a3c\u30c8\u30fc\u30af\u30f3\u3092<strong>\u660e\u793a\u7684\u306a\u5165\u529b\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc<\/strong>\u3068\u3057\u3066\u6e21\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684:<\/strong> \u30b9\u30af\u30ea\u30d7\u30c8\u3084CLI\u30c4\u30fc\u30eb\u304c\u3001\u8a8d\u8a3c\u3055\u308c\u305f\u72b6\u614b\u3067GitHub\u30ea\u30bd\u30fc\u30b9\u3092\u64cd\u4f5c\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>jobs:\n  open-issue:\n    # ... \u305d\u306e\u4ed6\u306e\u8a2d\u5b9a ...\n    steps:\n      - run: |\n          # gh issue create \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\n          gh issue --repo ${{ github.repository }} \\\n            create --title &quot;Issue title&quot; --body &quot;Issue body&quot;        \n        env: # &lt;--- \u74b0\u5883\u5909\u6570\u3068\u3057\u3066\u30c8\u30fc\u30af\u30f3\u3092\u8a2d\u5b9a\n          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # \u30c8\u30fc\u30af\u30f3\u3092GH_TOKEN\u3068\u3057\u3066\u6e21\u3059<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f8b 2: GitHub REST API\u3092\u76f4\u63a5\u547c\u3073\u51fa\u3059<\/h3>\n\n\n\n<p><code>curl<\/code> \u306a\u3069\u306e\u30c4\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u3001GitHub REST API\u306e\u7279\u5b9a\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u76f4\u63a5\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u3001\u8a8d\u8a3c\u6e08\u307f\u306e\u64cd\u4f5c\uff08Issue\u306e\u4f5c\u6210\u306a\u3069\uff09\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u76ee\u7684:<\/strong> GitHub Actions\u306b\u7d44\u307f\u8fbc\u307e\u308c\u3066\u3044\u306a\u3044\u3001\u7279\u5b9a\u306eAPI\u6a5f\u80fd\u3092\u5229\u7528\u3059\u308b\u3002<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>jobs:\n  create_issue:\n    # ... \u305d\u306e\u4ed6\u306e\u8a2d\u5b9a ...\n    steps:\n      - name: Create issue using REST API\n        run: |\n          curl --request POST \\\n          --url https:\/\/api.github.com\/repos\/${{ github.repository }}\/issues \\\n          --header &#39;authorization: Bearer ${{ secrets.GITHUB_TOKEN }}&#39; # &lt;--- Bearer\u30c8\u30fc\u30af\u30f3\u3068\u3057\u3066\u8a8d\u8a3c\u60c5\u5831\u3092\u6e21\u3059\n          # ... API\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30da\u30a4\u30ed\u30fc\u30c9 (\u30bf\u30a4\u30c8\u30eb\u3001\u672c\u6587\u306a\u3069) ...<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f512; \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5f37\u5316\uff1a\u30a2\u30af\u30bb\u30b9\u8a31\u53ef\uff08Permissions\uff09\u306e\u8a2d\u5b9a<\/h2>\n\n\n\n<p><code>GITHUB_TOKEN<\/code> \u306f\u5f37\u529b\u306a\u305f\u3081\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3068\u3057\u3066\u3001<strong>\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u307e\u305f\u306f\u30b8\u30e7\u30d6\u3054\u3068\u306b\u5fc5\u8981\u6700\u5c0f\u9650\u306e\u30a2\u30af\u30bb\u30b9\u6a29\u306e\u307f<\/strong>\u3092\u4ed8\u4e0e\u3059\u308b\u3053\u3068\u304c\u5f37\u304f\u63a8\u5968\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u8a2d\u5b9a\u306b\u306f\u3001\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u30d5\u30a1\u30a4\u30eb\u5185\u306e <strong><code>permissions<\/code><\/strong> \u30ad\u30fc\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f4cc; <code>permissions<\/code> \u30ad\u30fc\u306e\u5f79\u5272<\/h3>\n\n\n\n<p><code>permissions<\/code> \u30ad\u30fc\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001<code>GITHUB_TOKEN<\/code> \u304c\u3069\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u30ea\u30bd\u30fc\u30b9\uff08Issue\u3001Contents\u3001Pull Requests\u306a\u3069\uff09\u306b\u5bfe\u3057\u3066\u300c\u8aad\u307f\u53d6\u308a (<code>read<\/code>)\u300d\u307e\u305f\u306f\u300c\u66f8\u304d\u8fbc\u307f (<code>write<\/code>)\u300d\u6a29\u9650\u3092\u6301\u3064\u304b\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u4f8b<\/h4>\n\n\n\n<p>\u4f8b 1\u3067\u306f\u3001<code>issues: write<\/code> \u3068 <code>contents: read<\/code> \u306e2\u3064\u306e\u6a29\u9650\u306e\u307f\u3092\u30b8\u30e7\u30d6\u306b\u4ed8\u4e0e\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>jobs:\n  open-issue:\n    runs-on: ubuntu-latest\n    permissions: # &lt;--- GITHUB_TOKEN\u306e\u6a29\u9650\u3092\u3053\u3053\u3067\u5236\u9650\n      contents: read  # \u30b3\u30fc\u30c9\u306e\u8aad\u307f\u53d6\u308a\u306e\u307f\u8a31\u53ef\n      issues: write # Issue\u306e\u4f5c\u6210\u30fb\u7de8\u96c6\u3092\u8a31\u53ef\n    steps:\n      # ... Issue\u3092\u4f5c\u6210\u3059\u308b\u30b9\u30c6\u30c3\u30d7 ...<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>GITHUB_TOKEN \u306f\u3001GitHub Actions\u306e\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u304c\u5b9f\u884c\u3055\u308c\u308b\u305f\u3073\u306b\u81ea\u52d5\u7684\u306b\u751f\u6210\u3055\u308c\u308b\u4e00\u6642\u7684\u306a\u8a8d\u8a3c\u30c8\u30fc\u30af\u30f3\u3067\u3059\u3002 \u3053\u308c\u306f\u3001\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u5185\u3067\u5b9f\u884c\u3055\u308c\u308b\u30a2\u30af\u30b7\u30e7\u30f3\u3084\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u3001GitHub Actio<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jin_ogp_image_url":"","_jin_last_featured_id":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3217","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/3217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3217"}],"version-history":[{"count":1,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/3217\/revisions"}],"predecessor-version":[{"id":3223,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/3217\/revisions\/3223"}],"wp:attachment":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}