(ci): test changes in ci #24
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: Build and deploy changes | |
on: | |
push: | |
branches: [main] | |
paths: | |
- 'apps/web/**' | |
- 'apps/extension/**' | |
- 'apps/cf-ai-backend/**' | |
pull_request: | |
branches: [main] | |
paths: | |
- 'apps/web/**' | |
- 'apps/extension/**' | |
- 'apps/cf-ai-backend/**' | |
jobs: | |
check-modified-paths: | |
runs-on: ubuntu-latest | |
outputs: | |
web_changed: ${{ steps.set-outputs.outputs.web_changed }} | |
extension_changed: ${{ steps.set-outputs.outputs.extension_changed }} | |
cf_ai_backend_changed: ${{ steps.set-outputs.outputs.cf_ai_backend_changed }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Check modified paths | |
id: set-outputs | |
run: | | |
echo "Checking modified paths..." | |
# Custom script to check if specific paths were modified | |
# You might need to adjust the script based on your requirements | |
WEB_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'apps/web/' && echo 'true' || echo 'false') | |
EXTENSION_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'apps/extension/' && echo 'true' || echo 'false') | |
CF_AI_BACKEND_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'apps/cf-ai-backend/' && echo 'true' || echo 'false') | |
echo "::set-output name=web_changed::$WEB_CHANGED" | |
echo "::set-output name=extension_changed::$EXTENSION_CHANGED" | |
echo "::set-output name=cf_ai_backend_changed::$CF_AI_BACKEND_CHANGED" | |
build-extension: | |
needs: check-modified-paths | |
if: needs.check-modified-paths.outputs.extension_changed == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/buildextension | |
build-app: | |
if: contains(github.event.head_commit.modified, 'apps/web/') || contains(github.event.head_commit.added, 'apps/web/') || contains(github.event.head_commit.removed, 'apps/web/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install packages | |
run: bun i | |
shell: bash | |
- name: Build app | |
run: bun run pages:build | |
working-directory: apps/web | |
shell: bash | |
env: | |
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} | |
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} | |
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }} | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }} | |
BACKEND_SECURITY_KEY: ${{ secrets.BACKEND_SECURITY_KEY }} | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} | |
directory: apps/web/.vercel/output/static | |
branch: main | |
deploy-cf-worker: | |
if: contains(github.event.head_commit.modified, 'apps/cf-ai-backend/') || contains(github.event.head_commit.added, 'apps/cf-ai-backend/') || contains(github.event.head_commit.removed, 'apps/cf-ai-backend/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Deploy to Cloudflare Workers | |
uses: cloudflare/[email protected] | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
script: wrangler publish | |
working-directory: apps/cf-ai-backend | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
SECURITY_KEY: ${{ secrets.BACKEND_SECURITY_KEY }} |