diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f70281..b13d555 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,11 +15,13 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v6 + with: + fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v6 with: - node-version: '20' + node-version: "20" - name: Install dependencies run: npm ci @@ -43,7 +45,24 @@ jobs: run: | npx spectral lint schemas/core/openapi.yaml schemas/gcp/openapi.yaml --format github-actions --fail-severity warn + - name: Check for contract changes + id: contract + run: | + BASE_REF="${{ github.event.pull_request.base.sha || github.event.before }}" + if [ -z "$BASE_REF" ] || ! git cat-file -e "$BASE_REF" 2>/dev/null; then + echo "changed=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + CHANGED=$(git diff --name-only "$BASE_REF" HEAD -- '*.tsp') + if [ -n "$CHANGED" ]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + else + echo "changed=false" >> "$GITHUB_OUTPUT" + echo "No contract files changed — skipping version bump check" + fi + - name: Check version bump + if: steps.contract.outputs.changed == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: |