Skip to content

Commit

Permalink
FEAT | Stg pipeline (#45)
Browse files Browse the repository at this point in the history
* chore: update staging pipeline

* feat: stg pipeline
FIX | Add .env (#46)

* chore: update staging pipeline

* feat: stg pipeline

* feat: create .env
FIX | Fix stg pipeline

fix: fix pipeline

fix: fix pipeline
  • Loading branch information
Kittonn committed Nov 21, 2024
1 parent 6fd649c commit 01bb576
Show file tree
Hide file tree
Showing 9 changed files with 3,244 additions and 2,348 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
NOCODB_API_URL=
NOCODB_API_TOKEN=
NOCODB_API_TOKEN=

NOCODB_API_URL=https://noco.kitton.dev/api/v2/tables
NOCODB_API_TOKEN=AyLWAtLL-1dPYRKA4w1vLpJiiN3oo_cBpGECG0mz
31 changes: 0 additions & 31 deletions .github/workflows/cd.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/ci.yml

This file was deleted.

13 changes: 8 additions & 5 deletions .github/workflows/deploy.yml → .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI/CD
on:
push:
branches:
- develop
- main

jobs:
build:
Expand All @@ -28,12 +28,15 @@ jobs:
- name: Build and push the Docker image
uses: docker/build-push-action@v3
with:
build-args: |
NEXT_PUBLIC_API_URL=${{secrets.NEXT_PUBLIC_API_URL_PRD}}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/ce-next-gen/${{ github.event.repository.name }}-prd:latest
secrets: |
NOCODB_API_TOKEN=${{ secrets.NOCODB_API_TOKEN }}
NOCODB_API_URL=${{ secrets.NOCODB_API_URL }}
deploy:
name: Deploy
needs: build
Expand All @@ -47,4 +50,4 @@ jobs:
microk8s kubectl apply -f deploy/deployment.yml
microk8s kubectl rollout restart deployment/ce-next-gen-2024-frontend-prd -n ce-next-gen-prd
microk8s kubectl apply -f deploy/service.yml
microk8s kubectl apply -f deploy/ingress.yml
microk8s kubectl apply -f deploy/ingress.yml
69 changes: 69 additions & 0 deletions .github/workflows/stg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CICD Staging

on:
push:
branches:
- develop

env:
NOCODB_API_TOKEN: ${{ secrets.STG_NOCODB_API_TOKEN }}
NOCODB_API_URL: ${{ secrets.STG_NOCODB_API_URL }}

jobs:
build:
name: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GTK }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/ce-smart-career/${{ github.event.repository.name }}-stg:latest
secrets: |
NOCODB_API_TOKEN=${{ secrets.STG_NOCODB_API_TOKEN }}
NOCODB_API_URL=${{ secrets.STG_NOCODB_API_URL }}
deploy:
name: deploy
needs: ['build']
runs-on: [self-hosted, runner-stg]
permissions:
contents: read
packages: read

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GTK }}

- name: Deploy docker-compose stack
run: docker compose up -d --build --force-recreate

- name: Prune Docker system
run: docker system prune -af
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ FROM base AS builder
COPY --from=deps --chown=nextjs:nodejs /usr/app/node_modules ./node_modules
COPY . .

RUN pnpm run build
RUN --mount=type=secret,id=NOCODB_API_URL,env=NOCODB_API_URL \
--mount=type=secret,id=NOCODB_API_TOKEN,env=NOCODB_API_TOKEN \
pnpm run build

FROM node:20-alpine AS runner

Expand Down
9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
services:
ce-smart-career:
container_name: ce-smart-career
build:
context: .
dockerfile: Dockerfile
image: ghcr.io/ce-smart-career/ce-smart-career-2024-stg:latest
restart: always
ports:
- 3000:3000
- '3000:3000'
environment:
- NOCODB_API_URL
- NOCODB_API_TOKEN
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"pnpm": "^9.12.2",
"react": "^18",
"react-dom": "^18",
"sharp": "^0.33.5",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7"
},
Expand Down
Loading

0 comments on commit 01bb576

Please sign in to comment.