diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3359926..033cd4d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,6 +5,12 @@ on: push: branches: - 'feature/**' + - 'feat/**' + - 'fix/**' + - 'bugfix/**' + pull_request: + branches: + - main jobs: build-and-test: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 9880b50..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,118 +0,0 @@ -name: Deploy - -# Fires when a PR into main is closed. The `if: github.event.pull_request.merged -# == true` guard on every job filters out PRs that were closed without -# merging. Render's deploy hooks always rebuild the *latest commit already on -# the branch a service tracks* — they can't deploy an arbitrary unmerged PR — -# so deploying only makes sense once the code has actually landed on main. -on: - pull_request: - types: [closed] - branches: [main] - -jobs: - # Re-verified here (not just trusted from the PR check) in case the merged - # commit differs from what was last checked, e.g. a stale PR or a - # branch-protection bypass. - build: - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: 'npm' - - - name: Install dependencies - run: npm install - - - name: Build static site - run: node src/build-site.js - - test: - needs: build - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' - cache: 'npm' - - - name: Install dependencies - run: npm install - - - name: Run unit tests - run: npm test - - # Staging is a full mirror of production: its own Render Static Site and - # Web Service, deployed on every merge to main so it always reflects main's - # current state. This is what "staging must pass" means for the - # release-branch flow below — it's proven on this exact merged commit. - deploy-staging: - needs: test - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - environment: staging - steps: - - name: Trigger staging site deploy - run: curl -fsS -X POST "${{ secrets.RENDER_SITE_DEPLOY_HOOK }}" - - - name: Trigger staging API deploy - run: curl -fsS -X POST "${{ secrets.RENDER_API_DEPLOY_HOOK }}" - - smoke-test-staging: - needs: deploy-staging - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - environment: staging - steps: - # Render deploys asynchronously and free-tier services can take a - # while to build/boot, so give it a head start before checking. - - name: Wait for Render deploys to finish - run: sleep 60 - - - name: Smoke test staging site - run: curl -sSL "${{ vars.SITE_URL }}" | grep "Hello, World!" - - - name: Smoke test staging API - run: curl -sSL "${{ vars.API_URL }}/api/hello" | grep "Hello, World!" - - # Only runs when a release/* branch was merged — this is the "deploy only - # works when we merge a release branch to main" gate. It also only runs if - # smoke-test-staging succeeded (via `needs:`), so production can never - # deploy without staging having passed on this same commit first. - deploy-production: - needs: smoke-test-staging - if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') - runs-on: ubuntu-latest - environment: production - steps: - - name: Trigger production site deploy - run: curl -fsS -X POST "${{ secrets.RENDER_SITE_DEPLOY_HOOK }}" - - - name: Trigger production API deploy - run: curl -fsS -X POST "${{ secrets.RENDER_API_DEPLOY_HOOK }}" - - smoke-test-production: - needs: deploy-production - if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') - runs-on: ubuntu-latest - environment: production - steps: - - name: Wait for Render deploys to finish - run: sleep 60 - - - name: Smoke test production site - run: curl -sSL "${{ vars.SITE_URL }}" | grep "Hello, World!" - - - name: Smoke test production API - run: curl -sSL "${{ vars.API_URL }}/api/hello" | grep "Hello, World!"