diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index f9e8e9a..bc5748c 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -38,7 +38,12 @@ jobs: env: BASE: ${{ github.event.pull_request.base.sha || github.event.before }} run: | - if [ "$GITHUB_EVENT_NAME" = workflow_dispatch ] || [ -z "$BASE" ] || ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then + # A new branch's first push has no "before" commit (all zeros): compare it with main + # instead, so it tests only the recipes it changes. + if [ -z "$BASE" ] || ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then + BASE=$(git merge-base origin/main HEAD) + fi + if [ "$GITHUB_EVENT_NAME" = workflow_dispatch ]; then apps=$(ls -d apps/*/) else apps=$(git diff --name-only "$BASE" HEAD -- apps/ | cut -d/ -f1-2 | sort -u)