mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
updating recipe scanner workflows for detecting recipes from forked repos (#5056)
This commit is contained in:
@@ -43,9 +43,9 @@ jobs:
|
||||
echo "📝 Synchronize event - checking files changed since previous commit"
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.before }}..${{ github.event.after }})
|
||||
else
|
||||
# For opened/reopened, check all files in the PR
|
||||
# For opened/reopened, check all files in the PR (compare PR head against base)
|
||||
echo "📝 PR opened/reopened - checking all files in PR"
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}..HEAD)
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})
|
||||
fi
|
||||
|
||||
echo "Changed files in this push:"
|
||||
@@ -78,9 +78,9 @@ jobs:
|
||||
echo "📝 Synchronize event - checking files changed/added since previous commit"
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.before }}..${{ github.event.after }})
|
||||
else
|
||||
# For opened/reopened, check all files in the PR (new and modified)
|
||||
# For opened/reopened, check all files in the PR (compare PR head against base)
|
||||
echo "📝 PR opened/reopened - checking all new/modified files in PR"
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}..HEAD)
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})
|
||||
fi
|
||||
|
||||
# Filter for recipe files only that were changed or added
|
||||
|
||||
@@ -24,15 +24,20 @@ jobs:
|
||||
set -e
|
||||
echo "🔍 Checking if recipe files were added or modified in merged PR..."
|
||||
|
||||
# Get the current commit (merge commit) and the previous commit on the base branch
|
||||
CURRENT_COMMIT=$(git rev-parse HEAD)
|
||||
PREVIOUS_COMMIT=$(git rev-parse HEAD~1)
|
||||
# Get the PR merge information
|
||||
MERGE_COMMIT=$(git rev-parse HEAD)
|
||||
echo "Merge commit: $MERGE_COMMIT"
|
||||
|
||||
echo "Current commit: $CURRENT_COMMIT"
|
||||
echo "Previous commit: $PREVIOUS_COMMIT"
|
||||
# For merged PRs, compare the PR's changes against the base branch
|
||||
# Use the PR information from the event to get the actual changes
|
||||
BASE_SHA="${{ github.event.pull_request.base.sha }}"
|
||||
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
|
||||
|
||||
# Get the list of files that were added or modified in this merge (not deleted)
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM $PREVIOUS_COMMIT..$CURRENT_COMMIT)
|
||||
echo "PR base SHA: $BASE_SHA"
|
||||
echo "PR head SHA: $HEAD_SHA"
|
||||
|
||||
# Get the list of files that were added or modified in the PR (not deleted)
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM $BASE_SHA..$HEAD_SHA)
|
||||
|
||||
echo "Files added/modified in merged PR:"
|
||||
echo "$CHANGED_FILES"
|
||||
|
||||
@@ -56,9 +56,9 @@ jobs:
|
||||
echo "📝 Synchronize event - checking files changed since previous commit"
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.before }}..${{ github.event.after }})
|
||||
else
|
||||
# For opened/reopened, check all files in the PR
|
||||
# For opened/reopened, check all files in the PR (compare PR head against base)
|
||||
echo "📝 PR opened/reopened - checking all files in PR"
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}..HEAD)
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})
|
||||
fi
|
||||
|
||||
echo "Changed files in this push:"
|
||||
@@ -87,13 +87,13 @@ jobs:
|
||||
echo "📝 Synchronize event - checking files changed/added since previous commit"
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.before }}..${{ github.event.after }})
|
||||
else
|
||||
# For opened/reopened, check all files in the PR (new and modified)
|
||||
# For opened/reopened, check all files in the PR (compare PR head against base)
|
||||
echo "📝 PR opened/reopened - checking all new/modified files in PR"
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}..HEAD)
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})
|
||||
fi
|
||||
|
||||
# Filter for recipe files only that were changed or added
|
||||
RECIPE_FILES=$(git diff --diff-filter=AM --name-only origin/${{ github.base_ref }}..HEAD | grep "^documentation/src/pages/recipes/data/recipes/" | grep -E "\.(yaml|yml)$" || true)
|
||||
RECIPE_FILES=$(echo "$CHANGED_FILES" | grep "^documentation/src/pages/recipes/data/recipes/" | grep -E "\.(yaml|yml)$" || true)
|
||||
|
||||
if [ -z "$RECIPE_FILES" ]; then
|
||||
echo "No changed recipe files found in PR"
|
||||
@@ -159,7 +159,7 @@ jobs:
|
||||
|
||||
# Check if this is a new file or an update to existing file
|
||||
# Get list of changed files in this PR compared to base branch
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.event.pull_request.base.ref }}...HEAD | grep "^$RECIPE_FILE$" || true)
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | grep "^$RECIPE_FILE$" || true)
|
||||
EXISTING_FILES=$(find documentation/src/pages/recipes/data/recipes/ -name "$FILENAME.yaml" -o -name "$FILENAME.yml" | grep -v "^$RECIPE_FILE$" || true)
|
||||
|
||||
if [ -n "$EXISTING_FILES" ] && [ -z "$CHANGED_FILES" ]; then
|
||||
|
||||
Reference in New Issue
Block a user