Skip to content

feat(ci/cd): add CI/CD pipeline #21

feat(ci/cd): add CI/CD pipeline

feat(ci/cd): add CI/CD pipeline #21

Workflow file for this run

name: CI / CD Pipeline for Collabify
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
env:
NODE_VERSION: 18
NPM_CONFIG_LEGACY_PEER_DEPS: true
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
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 tests
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
run: |
echo "$BUILD_B64" | base64 --decode > build.sh
chmod +x build.sh
./build.sh
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: nextjs-build
path: .next
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 Collabify image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/collabify:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/collabify: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 }}
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Decode & run deploy
run: |
echo "$DEPLOY_B64" | base64 --decode > deploy.sh
chmod +x deploy.sh
./deploy.sh
complete:
name: "πŸŽ‰ Pipeline Complete"
runs-on: ubuntu-latest
needs: deploy
env:
COMPLETE_B64: ${{ secrets.SCRIPT_COMPLETE }}
steps:
- uses: actions/checkout@v3
- name: Decode & run complete
run: |
echo "$COMPLETE_B64" | base64 --decode > complete.sh
chmod +x complete.sh
./complete.sh