Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Next.js CI (develop → master)

on:
pull_request:
branches: [ "master" ]
types: [opened, synchronize, reopened]
# Only trigger if PR comes from develop branch
paths-ignore:
- "README.md"

jobs:
build:
if: github.base_ref == 'master' && github.head_ref == 'develop'
runs-on: ubuntu-latest

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

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Dependencies
run: npm install

- name: Build Next.js App
run: npm run build

- name: Run Tests (optional)
run: npm test
continue-on-error: true
46 changes: 46 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Next.js CI/CD

on:
push:
branches: [ "master" ] # use master branch
pull_request:
branches: [ "master" ]

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
# 1️⃣ Checkout the repo
- name: Checkout code
uses: actions/checkout@v4

# 2️⃣ Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20

# 3️⃣ Install dependencies
- name: Install dependencies
run: npm install --legacy-peer-deps

# 4️⃣ Build Next.js project
- name: Build Next.js
run: npm run build

# 5️⃣ Deploy to your server via SSH
- name: Deploy via SSH
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
port: 22
script: |
cd /var/www/myproject/website
git reset --hard
git pull origin master
npm install --legacy-peer-deps
npm run build
pm2 restart nextjs-website
5 changes: 5 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FORM ubuntu
RUN apt update
RUN apt install apache2 -y
ADD . /var/www/html
ENTRYPOINT apachectl -D FOREGROUND