Fix CI pipeline: deploy on main, webhook on PRs only, show failure output
All checks were successful
CI/CD Pipeline - Apartment API / Scan Dependencies (push) Successful in 13s
CI/CD Pipeline - Apartment API / Lint & Test (push) Successful in 44s
CI/CD Pipeline - Apartment API / Send Webhook Notification (push) Has been skipped
CI/CD Pipeline - Apartment API / Build & Push Image (push) Successful in 1m42s
CI/CD Pipeline - Apartment API / Deploy to Production (push) Successful in 14s

- Skip webhook notification on main branch pushes
- Gate build/deploy on lint and test success via CI outputs instead of
  notify job dependency
- Print lint and test output to step logs so failures are visible in
  the Actions UI
This commit is contained in:
2026-02-08 21:14:25 -07:00
parent 248f310121
commit 2b836e6faf

View File

@ -44,6 +44,7 @@ jobs:
set +e
OUTPUT=$(npm run lint 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
# Truncate before writing to GITHUB_OUTPUT to prevent
# "argument list too long" in downstream jobs
echo "lint_output<<EOF" >> $GITHUB_OUTPUT
@ -58,6 +59,7 @@ jobs:
set +e
OUTPUT=$(npm test -- --runInBand 2>&1)
EXIT_CODE=$?
echo "$OUTPUT"
# Truncate before writing to GITHUB_OUTPUT to prevent
# "argument list too long" in downstream jobs
echo "test_output<<EOF" >> $GITHUB_OUTPUT
@ -75,7 +77,7 @@ jobs:
name: Send Webhook Notification
runs-on: ubuntu-latest
needs: [ci]
if: always()
if: always() && github.ref != 'refs/heads/main'
steps:
- name: Send results to n8n webhook
@ -198,8 +200,12 @@ jobs:
build:
name: Build & Push Image
runs-on: ubuntu-latest
needs: [ci, scan-deps, notify]
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: [ci, scan-deps]
if: >-
github.ref == 'refs/heads/main' &&
github.event_name != 'pull_request' &&
needs.ci.outputs.lint_status == 'success' &&
needs.ci.outputs.test_status == 'success'
outputs:
image_tag: ${{ steps.set-tag.outputs.tag }}