Skip to content

Commit

Permalink
Commits from stagging branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Daoud-Hussain committed Nov 15, 2024
1 parent 722496c commit f958bb2
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 66 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/deploy.yml

This file was deleted.

72 changes: 72 additions & 0 deletions .github/workflows/dev-cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Dev CI/CD Pipeline

on:
push:
branches:
- dev
pull_request:
branches:
- dev

env:
IMAGE_NAME: daoudhussaindev/next-js-app

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build Next.js application
run: npm run build

test:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test

deploy:
runs-on: ubuntu-latest
needs: [test]
if: github.ref == 'refs/heads/dev'

steps:
- uses: actions/checkout@v4
- name: Build Docker image for dev
run: docker build -t ${{ env.IMAGE_NAME }}:dev .
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD_DEV }}" | docker login -u "${{ secrets.DOCKER_USERNAME_DEV }}" --password-stdin
- name: Push Docker image to Docker Hub (dev)
run: docker push ${{ env.IMAGE_NAME }}:dev
- name: Deploy to Dev Server
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.DEV_SERVER_USER }}@${{ secrets.DEV_SERVER_IP }} << 'EOF'
docker pull ${{ env.IMAGE_NAME }}:dev
docker stop dev-container || true
docker rm dev-container || true
docker run -d --name dev-container -p 3000:3000 ${{ env.IMAGE_NAME }}:dev
EOF
88 changes: 44 additions & 44 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@

name: Integration

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
# name: Integration

# on:
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]

# jobs:
# build:

# runs-on: ubuntu-latest

# strategy:
# matrix:
# node-version: [18.x, 20.x, 22.x]

# steps:
# - uses: actions/checkout@v4
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# cache: 'npm'

- name: "Installing Dependencies"
run: npm i
# - name: "Installing Dependencies"
# run: npm i

- name: "Build command"
run: npm run build
# - name: "Build command"
# run: npm run build

unit-tests:
# unit-tests:

runs-on: ubuntu-latest
# runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
# strategy:
# matrix:
# node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
# steps:
# - uses: actions/checkout@v4
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# cache: 'npm'

- name: "Installing Dependencies"
run: npm i
# - name: "Installing Dependencies"
# run: npm i

- name: "Running test cases"
run: npm run test
# - name: "Running test cases"
# run: npm run test

0 comments on commit f958bb2

Please sign in to comment.