Skip to content

feat(ci); update ci/cd pipeline and dockerfile #1

feat(ci); update ci/cd pipeline and dockerfile

feat(ci); update ci/cd pipeline and dockerfile #1

Workflow file for this run

name: CI / CD Pipeline for AI Assistant Template
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
env:
NODE_VERSION: 18
jobs:
formatting:
name: "🔧 Format & Lint"
runs-on: ubuntu-latest
env:
FMT_LINT_B64: ${{ secrets.SCRIPT_FORMAT_LINT }}
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Decode & run format-lint script
run: |
echo "$FMT_LINT_B64" | base64 --decode > fmt-lint.sh
chmod +x fmt-lint.sh
./fmt-lint.sh
testing:
name: "🧪 Test (Jest)"
runs-on: ubuntu-latest
needs: formatting
env:
TEST_B64: ${{ secrets.SCRIPT_TEST }}
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Decode & run test script
run: |
echo "$TEST_B64" | base64 --decode > test.sh
chmod +x test.sh
./test.sh
build:
name: "🏗 Build Next.js"
runs-on: ubuntu-latest
needs: testing
env:
BUILD_B64: ${{ secrets.SCRIPT_BUILD }}
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Decode & run build script
run: |
echo "$BUILD_B64" | base64 --decode > build.sh
chmod +x build.sh
./build.sh
docker:
name: "🐳 Build & Push Docker Image"
runs-on: ubuntu-latest
needs: testing
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & push custom-ai image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/custom-ai:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/custom-ai:latest
build-args: |
NODE_ENV=production
deploy:
name: "🚀 Deploy to Vercel"
runs-on: ubuntu-latest
needs:
- build
- docker
env:
DEPLOY_B64: ${{ secrets.SCRIPT_DEPLOY }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
- name: Decode & run deploy script
run: |
echo "$DEPLOY_B64" | base64 --decode > deploy.sh
chmod +x deploy.sh
./deploy.sh