5 Resource not accessible by integration Error
GitHub ActionsにおけるResource not accessible by integration Error
Resource not accessible by integration
error とは,文字通り「integration時にリソースにアクセスできない」ことを指しています. つまり,ワークフローが特定のリソース(リポジトリ、シークレット、環境など)にアクセスするための必要な権限を持っていないのが原因となります,
Solution: secrets.GITHUB_TOKEN
のPermission範囲変更
${{ secrets.GITHUB_TOKEN }}
のデフォルトPermissionは,該当するリポジトリの Settings > Actions > General > Workflow permissions
にて定められています.
Read and write permissions
Reead repository contents permission
の2つのレベルが選択できます.ワークフロー内容に合わせて設定しますが,Git tag運用に合わせたRelease noteの自動作成の場合は前者を選択する必要があります.
Example 5.1 : git tagに応じたrelease note作成ワークフロー
name: git tag version update
on:
pull_request:
branches:
- main
- master
types:
- closed
jobs:
build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Extract PR Comment
id: pr_comment
run: |
TAG=$(echo "$PULL_REQUEST_BODY" | grep -Po '(?<=tag: )v\.\d+\.\d+\.\d+')
if [ -n "$TAG" ]; then
gh release create $TAG --generate-notes
fi env:
GH_TOKEN: ${{ github.token }}
PULL_REQUEST_BODY: "${{ github.event.pull_request.body }}"