-
-
Notifications
You must be signed in to change notification settings - Fork 3
ci: use pull_request_target to fix token permissions #1407
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0894d79
ci: use pull_request_target to fix "Resource not accessible by integr…
claude bb5386a
ci: fix privilege escalation by splitting into two-workflow pattern
claude c3357ba
ci: add actions: read permission for cross-run artifact download
claude 6280bac
ci: use trusted event context for PR number and harden metadata reads
claude 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
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 |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Post data validation comment | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Verify station data integrity"] | ||
| types: [completed] | ||
|
|
||
| permissions: | ||
| actions: read | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
| jobs: | ||
| comment: | ||
| name: Post validation result comment | ||
| runs-on: ubuntu-latest | ||
| if: github.event.workflow_run.event == 'pull_request' | ||
| steps: | ||
| - name: Download artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: validation-result | ||
| path: /tmp/validation-artifacts | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ github.token }} | ||
|
|
||
| - name: Read metadata | ||
| id: meta | ||
| run: | | ||
| echo "pr_number=${{ github.event.workflow_run.pull_requests[0].number }}" >> "$GITHUB_OUTPUT" | ||
| if [ -s /tmp/validation-artifacts/result ]; then | ||
| echo "result=$(cat /tmp/validation-artifacts/result)" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "::error::Missing or empty result metadata" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Find existing comment | ||
| uses: peter-evans/find-comment@v3 | ||
| id: find_comment | ||
| with: | ||
| issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} | ||
| comment-author: "github-actions[bot]" | ||
| body-includes: "<!-- data-validator -->" | ||
|
|
||
| - name: Post or update validation failure comment | ||
| if: steps.meta.outputs.result == 'failure' | ||
| uses: peter-evans/create-or-update-comment@v4 | ||
| with: | ||
| issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} | ||
| comment-id: ${{ steps.find_comment.outputs.comment-id }} | ||
| body-path: /tmp/validation-artifacts/validation_report.md | ||
| edit-mode: replace | ||
|
|
||
| - name: Delete comment if validation passed | ||
| if: steps.meta.outputs.result == 'success' && steps.find_comment.outputs.comment-id != '' | ||
| run: gh api repos/${{ github.repository }}/issues/comments/${{ steps.find_comment.outputs.comment-id }} -X DELETE | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
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
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 |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Post stopping pattern visualization comment | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Visualize Stopping Patterns"] | ||
| types: [completed] | ||
|
|
||
| permissions: | ||
| actions: read | ||
| pull-requests: write | ||
| issues: write | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| jobs: | ||
| comment: | ||
| name: Post visualization comment | ||
| runs-on: ubuntu-latest | ||
| if: >- | ||
| github.event.workflow_run.conclusion == 'success' && | ||
| github.event.workflow_run.event == 'pull_request' | ||
| steps: | ||
| - name: Download artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: visualization-result | ||
| path: /tmp/visualize-artifacts | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ github.token }} | ||
|
|
||
| - name: Read metadata | ||
| id: meta | ||
| run: | | ||
| echo "pr_number=${{ github.event.workflow_run.pull_requests[0].number }}" >> "$GITHUB_OUTPUT" | ||
| if [ -s /tmp/visualize-artifacts/has_changes ]; then | ||
| echo "has_changes=$(cat /tmp/visualize-artifacts/has_changes)" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "::warning::has_changes metadata missing or empty, defaulting to false" | ||
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Find existing comment | ||
| uses: peter-evans/find-comment@v3 | ||
| id: find_comment | ||
| with: | ||
| issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} | ||
| comment-author: "github-actions[bot]" | ||
| body-includes: "<!-- station-visualizer -->" | ||
|
|
||
| - name: Post or update comment | ||
| if: steps.meta.outputs.has_changes == 'true' | ||
| uses: peter-evans/create-or-update-comment@v4 | ||
| with: | ||
| issue-number: ${{ github.event.workflow_run.pull_requests[0].number }} | ||
| comment-id: ${{ steps.find_comment.outputs.comment-id }} | ||
| body-path: /tmp/visualize-artifacts/visualization_comment.md | ||
| edit-mode: replace | ||
|
|
||
| - name: Delete comment if no changes | ||
| if: steps.meta.outputs.has_changes == 'false' && steps.find_comment.outputs.comment-id != '' | ||
| run: gh api repos/${{ github.repository }}/issues/comments/${{ steps.find_comment.outputs.comment-id }} -X DELETE | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
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.
Uh oh!
There was an error while loading. Please reload this page.