Skip to content

Commit

Permalink
Added ci/cd pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
hkirat committed Sep 15, 2024
1 parent 27d0052 commit ced9c5a
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Continuous Deployment
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

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

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.prod
push: true
tags: 100xdevs/job-board-staging:${{ github.sha }}

- name: Clone staging-ops repo, update, and push
env:
PAT: ${{ secrets.STAGING_OPS_PAT }}
run: |
git clone https://github.com/code100x/staging-ops.git
cd staging-ops
sed -i 's|image: 100xdevs/job-board-staging:.*|image: 100xdevs/job-board-staging:${{ github.sha }}|' job-board/deployment.yaml
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
git add job-board/deployment.yaml
git commit -m "Update job-board-staging image to ${{ github.sha }}"
git push https://${PAT}@github.com/code100x/staging-ops.git main
19 changes: 19 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

FROM node:20-alpine AS build
ARG DATABASE_URL
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN DATABASE_URL=$DATABASE_URL npx prisma generate
RUN DATABASE_URL=$DATABASE_URL npm run build

FROM node:20-alpine AS production
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/.next ./.next
COPY --from=build /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/public ./public
COPY --from=build /usr/src/app/package.json ./package.json
CMD ["npm", "run", "start"]

EXPOSE 3000
15 changes: 15 additions & 0 deletions prisma/migrations/20240915194739_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
Warnings:
- You are about to drop the column `location` on the `Job` table. All the data in the column will be lost.
- Added the required column `address` to the `Job` table without a default value. This is not possible if the table is not empty.
- Added the required column `city` to the `Job` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Job" DROP COLUMN "location",
ADD COLUMN "address" TEXT NOT NULL,
ADD COLUMN "city" TEXT NOT NULL;

-- DropEnum
DROP TYPE "JobLocations";

0 comments on commit ced9c5a

Please sign in to comment.