-
Notifications
You must be signed in to change notification settings - Fork 6
Validate fork PR plugins via pull_request_target #100
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
Changes from all commits
7d56da8
aa2e335
8a17b72
80f646e
e6c1489
f543268
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,17 @@ | ||
| name: Validate & Deploy Plugins | ||
|
|
||
| on: | ||
| pull_request: | ||
| # GitHub always resolves the workflow file (and GITHUB_REF/GITHUB_SHA) for | ||
| # pull_request_target from the repo's actual default branch, never the PR's own | ||
| # branch β so a PR editing this file (fork or not) can't change what runs against it. | ||
| pull_request_target: | ||
|
|
||
| # Serialize runs per PR so an older run (from a rapid follow-up push, or the transitional | ||
| # pull_request/pull_request_target overlap above) can't finish last and overwrite a newer | ||
| # deploy that reuses the same --suffix. | ||
| concurrency: | ||
| group: pr-run-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
Comment on lines
+9
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ποΈ Data Integrity & Integration | π Major | ποΈ Heavy lift π§© Analysis chainπ Script executed: #!/bin/bash
set -euo pipefail
# Map the workflow file structure first, then inspect the relevant slices.
ast-grep outline .github/workflows/pr-run.yaml --view expanded || true
printf '\n--- workflow excerpt ---\n'
cat -n .github/workflows/pr-run.yaml | sed -n '1,260p'Repository: squaredup/plugins Length of output: 10060 π Script executed: #!/bin/bash
set -euo pipefail
# Find where the workflow uses pull_request / pull_request_target and where deploy happens.
rg -n "pull_request_target|pull_request|concurrency|cancel-in-progress|squaredup deploy|PLUGIN_PATHS|comments|API_KEY|token" .github/workflows/pr-run.yaml .github/workflows -g '*.yaml' -g '*.yml'Repository: squaredup/plugins Length of output: 5382 π Script executed: #!/bin/bash
set -euo pipefail
printf '\n--- pr-cleanup workflow ---\n'
if [ -f .github/workflows/pr-cleanup.yaml ]; then
cat -n .github/workflows/pr-cleanup.yaml
else
echo "missing"
fi
printf '\n--- deploy-related references ---\n'
rg -n "squaredup deploy|cleanup|suffix|cancel-in-progress|concurrency" .github/workflows -g '*.yml' -g '*.yaml'Repository: squaredup/plugins Length of output: 1990 π Script executed: #!/bin/bash
set -euo pipefail
# Inspect any docs or code that describe squaredup deploy behavior or suffix cleanup.
rg -n "squaredup deploy|--suffix|pr-cleanup|cleanup old|remove.*deployment|undeploy|delete.*deployment|tenant" . -g '*.md' -g '*.yaml' -g '*.yml' -g '*.js' -g '*.ts' -g '*.sh'Repository: squaredup/plugins Length of output: 541 Separate validation from deployment concurrency π€ Prompt for AI AgentsSource: MCP tools |
||
|
|
||
| jobs: | ||
| validate-and-deploy: | ||
|
|
@@ -11,6 +21,7 @@ jobs: | |
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Detect modified plugins | ||
|
|
@@ -37,14 +48,18 @@ jobs: | |
| env: | ||
| SQUAREDUP_API_KEY: ${{ secrets.SQUAREDUP_API_KEY }} | ||
| run: | | ||
| echo "Installing SquaredUp CLI..." | ||
| npm install -g @squaredup/cli | ||
| echo "Configuring SquaredUp CLI with API key..." | ||
| squaredup login --apiKey "$SQUAREDUP_API_KEY" | ||
| echo "Installing SquaredUp CLI..." | ||
| cd "$RUNNER_TEMP" | ||
| npm install -g @squaredup/cli | ||
| echo "SquaredUp CLI version: $(squaredup -v)" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| echo "Configuring SquaredUp CLI with API key..." | ||
| squaredup login --apiKey "$SQUAREDUP_API_KEY" | ||
|
|
||
| - name: Validate modified plugins | ||
| id: validate | ||
| if: steps.detect.outputs.plugins_modified == 'true' | ||
| env: | ||
| PLUGIN_PATHS: ${{ steps.detect.outputs.plugin_paths }} | ||
| run: | | ||
| validation_failed=false | ||
|
|
||
|
|
@@ -66,7 +81,7 @@ jobs: | |
| validation_failed=true | ||
| fi | ||
| echo "" | ||
| done <<< "${{ steps.detect.outputs.plugin_paths }}" | ||
| done <<< "$PLUGIN_PATHS" | ||
|
|
||
| if [ "$validation_failed" = "true" ]; then | ||
| echo "One or more plugins failed validation." | ||
|
|
@@ -76,16 +91,20 @@ jobs: | |
| - name: Deploy modified plugins | ||
| id: deploy | ||
| if: steps.detect.outputs.plugins_modified == 'true' | ||
| env: | ||
| PLUGIN_PATHS: ${{ steps.detect.outputs.plugin_paths }} | ||
| run: | | ||
| while IFS= read -r plugin_path; do | ||
| echo "Deploying ${plugin_path}..." | ||
| squaredup deploy "${plugin_path}" --suffix "${{ github.event.pull_request.number }}" --force | ||
| echo "Deployed ${plugin_path} successfully." | ||
| echo "" | ||
| done <<< "${{ steps.detect.outputs.plugin_paths }}" | ||
| done <<< "$PLUGIN_PATHS" | ||
|
|
||
| - name: Summary | ||
| if: always() | ||
| env: | ||
| PLUGIN_PATHS: ${{ steps.detect.outputs.plugin_paths }} | ||
| run: | | ||
| OUT=/tmp/summary.md | ||
|
|
||
|
|
@@ -101,7 +120,7 @@ jobs: | |
| echo "### π¦ Modified Plugins" >> $OUT | ||
| while IFS= read -r plugin_path; do | ||
| echo "- \`${plugin_path}\`" >> $OUT | ||
| done <<< "${{ steps.detect.outputs.plugin_paths }}" | ||
| done <<< "$PLUGIN_PATHS" | ||
| echo "" >> $OUT | ||
|
|
||
| echo "### π Results" >> $OUT | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.