diff --git a/.github/workflows/recipe-security-scanner.yml b/.github/workflows/recipe-security-scanner.yml index 7531ba41723e..88084eb3fb80 100644 --- a/.github/workflows/recipe-security-scanner.yml +++ b/.github/workflows/recipe-security-scanner.yml @@ -36,15 +36,15 @@ jobs: set -e echo "🔍 Checking if recipe files were modified in this push..." - # Get the list of changed files in this specific push + # Get the list of changed files in this specific push (added/modified only, not deleted) if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "synchronize" ]; then # For synchronize events, check files changed since the previous commit echo "📝 Synchronize event - checking files changed since previous commit" - CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }}) + 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 echo "📝 PR opened/reopened - checking all files in PR" - CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD) + CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}..HEAD) fi echo "Changed files in this push:" @@ -71,15 +71,15 @@ jobs: set -e echo "Looking for recipe files in PR (new or modified)..." - # Get the list of changed/new files in this PR + # Get the list of changed/new files in this PR (added/modified only, not deleted) if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "synchronize" ]; then # For synchronize events, check files changed since the previous commit echo "📝 Synchronize event - checking files changed/added since previous commit" - CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }}) + 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) echo "📝 PR opened/reopened - checking all new/modified files in PR" - CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD) + CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}..HEAD) fi # Filter for recipe files only that were changed or added diff --git a/.github/workflows/send-api-key.yml b/.github/workflows/send-api-key.yml index bb3fa86379e8..d21d4a5f1410 100644 --- a/.github/workflows/send-api-key.yml +++ b/.github/workflows/send-api-key.yml @@ -15,13 +15,39 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Check if recipe files were added or modified in merged PR + id: recipe_changes + run: | + set -e + echo "🔍 Checking if recipe files were added or modified in merged PR..." + + # Get the list of files that were added or modified in the merged PR (not deleted) + CHANGED_FILES=$(git diff --name-only --diff-filter=AM ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) + + echo "Files added/modified in merged PR:" + echo "$CHANGED_FILES" + echo "" + + # Check if any recipe files were added or modified + if echo "$CHANGED_FILES" | grep -q "^documentation/src/pages/recipes/data/recipes/"; then + echo "recipe_files_changed=true" >> "$GITHUB_OUTPUT" + echo "✅ Recipe files were added/modified in merged PR - proceeding with API key sending" + else + echo "recipe_files_changed=false" >> "$GITHUB_OUTPUT" + echo "â„šī¸ No recipe files were added/modified in merged PR - skipping API key sending" + fi - name: Set up Python + if: steps.recipe_changes.outputs.recipe_files_changed == 'true' uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install dependencies and run email script + if: steps.recipe_changes.outputs.recipe_files_changed == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/validate-recipe-pr.yml b/.github/workflows/validate-recipe-pr.yml index b80cf4b37afb..ed4c1b72edd8 100644 --- a/.github/workflows/validate-recipe-pr.yml +++ b/.github/workflows/validate-recipe-pr.yml @@ -49,15 +49,15 @@ jobs: set -e echo "🔍 Checking if recipe files were modified in this push..." - # Get the list of changed files in this specific push + # Get the list of changed files in this specific push (added/modified only, not deleted) if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "synchronize" ]; then # For synchronize events, check files changed since the previous commit echo "📝 Synchronize event - checking files changed since previous commit" - CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }}) + 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 echo "📝 PR opened/reopened - checking all files in PR" - CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD) + CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}..HEAD) fi echo "Changed files in this push:" @@ -80,15 +80,15 @@ jobs: set -e echo "Looking for recipe files in PR (new or modified)..." - # Get the list of changed/new files in this PR + # Get the list of changed/new files in this PR (added/modified only, not deleted) if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.action }}" = "synchronize" ]; then # For synchronize events, check files changed since the previous commit echo "📝 Synchronize event - checking files changed/added since previous commit" - CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }}) + 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) echo "📝 PR opened/reopened - checking all new/modified files in PR" - CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD) + CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }}..HEAD) fi # Filter for recipe files only that were changed or added