-
Notifications
You must be signed in to change notification settings - Fork 3
test suzuki-shunsuke/tibdex-github-app-token #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
suzuki-shunsuke
wants to merge
1
commit into
main
Choose a base branch
from
test-tibdex-github-app-token-fork
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,19 @@ | ||
| --- | ||
| name: test | ||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| pull_request_review: | ||
| types: [submitted] | ||
| on: pull_request | ||
| jobs: | ||
| test: | ||
| if: | | ||
| endsWith(github.event.pull_request.user.login, '[bot]') && | ||
| ((github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || | ||
| github.event_name == 'pull_request') | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| pull-requests: write | ||
| contents: read | ||
| permissions: {} | ||
| steps: | ||
| - uses: suzuki-shunsuke/notify-bot-pr-event-action@pr/1 | ||
| - id: create_token | ||
| uses: suzuki-shunsuke/tibdex-github-app-token@55429bbc082600559820fc71ef237b3f0e2a50a1 # v3.0.0 | ||
| with: | ||
| app_id: ${{ vars.APP_ID }} | ||
| private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
| - run: gh pr comment -R "$GITHUB_REPOSITORY" "$NUMBER" --body "$BODY" | ||
| env: | ||
| GH_TOKEN: ${{ steps.create_token.outputs.token }} | ||
| NUMBER: ${{ github.event.pull_request.number }} | ||
| BODY: hello | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
For GitHub Actions, are repository secrets available to workflows triggered bypull_requestfrom forks, and when ispull_request_targetthe correct alternative?💡 Result:
Yes—when a workflow is triggered by
pull_requestfrom a fork, GitHub does not pass repository secrets to the runner (with the exception ofGITHUB_TOKEN). [1][2] When to usepull_request_target: use it when you need access to the base repository’s secrets (or otherwise need the privileged context of the target repository) while responding to a pull request. GitHub introducedpull_request_targetspecifically to give the workflow access to secrets/read-writeGITHUB_TOKENso maintainers can safely perform tasks like commenting/labeling on PRs. [3] However,pull_request_targetis dangerous if your workflow checks out and runs untrusted code from the pull request; GitHub’s Security Lab warns that combining it with an explicit checkout/build/run of untrusted PR code can lead to repository compromise, because the workflow runs in the context of the base repo with secrets available. [4] Rule of thumb: - If you only need to test untrusted code: preferpull_request(secrets withheld by design). [4][2] - If you truly need base repo secrets: usepull_request_target, but do not blindly execute the PR’s code—only use it for trusted tasks, and/or gate execution carefully (e.g., separate trusted workflow steps, approvals, and strict handling of what is checked out/executed). [4] Related note: for fork PRs usingpull_request_target, GitHub documents thatGITHUB_TOKENis granted read/write repository permission even when triggered from a public fork. [5]Citations:
🏁 Script executed:
Repository: szksh-lab-2/test-github-action
Length of output: 797
pull_requestprevents app-secret usage on fork PRs.Line 3 + Line 14 are incompatible for forked PR validation:
secrets.APP_PRIVATE_KEYis not available on fork-triggeredpull_requestruns, so token creation fails and thegh pr commentstep cannot execute.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents