CD #45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | |
on: | |
workflow_run: | |
workflows: ['CI'] | |
types: | |
- completed | |
branches: | |
- main | |
env: | |
NEXT_PUBLIC_DATABASE_URL: ${{ secrets.NEXT_PUBLIC_DATABASE_URL }} | |
DWOLLA_ENV: ${{ secrets.DWOLLA_ENV }} | |
DWOLLA_KEY: ${{ secrets.DWOLLA_KEY}} | |
DWOLLA_SECRET: ${{ secrets.DWOLLA_SECRET }} | |
jobs: | |
check-affected: | |
if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main'}} | |
name: Check affected projects | |
runs-on: ubuntu-latest | |
outputs: | |
banking: ${{ steps.set-output.outputs.banking }} | |
next-dashboard: ${{ steps.set-output.outputs.next-dashboard }} | |
ai-content-generator: ${{ steps.set-output.outputs.ai-content-generator }} | |
steps: | |
- name: Checkout the source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install --no-cache | |
- name: 'Derive approperiate SHAs for base and head for `nx affected` commands' | |
uses: nrwl/nx-set-shas@v4 | |
- name: Check affected projects | |
id: affected | |
run: | | |
bunx nx show projects --affected --base=$NX_BASE --head=$NX_HEAD --select=projects > affected.json | |
- name: Display affected projects | |
run: cat affected.json | |
- name: Set output for affected projects | |
id: set-output | |
run: | | |
AFFECTED_PROJECTS=$(cat affected.json) | |
if [[ $AFFECTED_PROJECTS == *"banking"* ]]; then | |
echo "::set-output name=banking::1" | |
else | |
echo "::set-output name=banking::0" | |
fi | |
if [[ $AFFECTED_PROJECTS == *"next-dashboard"* ]]; then | |
echo "::set-output name=next-dashboard::1" | |
else | |
echo "::set-output name=next-dashboard::0" | |
fi | |
if [[ $AFFECTED_PROJECTS == *"ai-content-generator"* ]]; then | |
echo "::set-output name=ai-content-generator::1" | |
else | |
echo "::set-output name=ai-content-generator::0" | |
fi | |
deploy-banking: | |
needs: check-affected | |
if: ${{ needs.check-affected.outputs.banking == '1'}} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install --no-cache | |
- name: 'Derive approperiate SHAs for base and head for `nx affected` commands' | |
uses: nrwl/nx-set-shas@v4 | |
- name: Build banking project | |
run: bunx nx run banking:build | |
- name: List build directory contents | |
run: ls -la apps/banking/.next | |
- name: Deploy 'banking' project to Netlify | |
run: curl -X POST -d {} ${{ secrets.BANKING_NETLIFY_DEPLOY_HOOK_URL }} | |
deploy-next-dashboard: | |
needs: check-affected | |
if: ${{ needs.check-affected.outputs.next-dashboard == '1'}} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install --no-cache | |
- name: 'Derive approperiate SHAs for base and head for `nx affected` commands' | |
uses: nrwl/nx-set-shas@v4 | |
- name: Build next-dashboard project | |
run: bunx nx run next-dashboard:build | |
- name: List build directory contents | |
run: ls -la apps/next-dashboard/.next | |
- name: Deploy 'next-dashboard' project to Vercel | |
run: curl -X POST -d {} ${{ secrets.NEXT_DASHBOARD_VERCEL_DEPLOY_HOOK_URL }} | |
deploy-ai-content-generator: | |
needs: check-affected | |
if: ${{ needs.check-affected.outputs.ai-content-generator == '1'}} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: bun install --no-cache | |
- name: 'Derive approperiate SHAs for base and head for `nx affected` commands' | |
uses: nrwl/nx-set-shas@v4 | |
- name: Build ai-content-generator project | |
run: bunx nx run ai-content-generator:build | |
- name: List build directory contents | |
run: ls -la apps/ai-content-generator/.next | |
- name: Deploy 'ai-content-generator' project to Netlify | |
run: curl -X POST -d {} ${{ secrets.AI_CONTENT_GENERATOR_NETLIFY_DEPLOY_HOOK_URL }} |