Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Workflows into the project for deployment #209

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
189 changes: 127 additions & 62 deletions .github/workflows/nextjs-app-ci.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,127 @@
name: Next.js App CI
on:
push:
branches: ["*"]
paths-ignore:
- "README.md"
- "docs/**"
pull_request:
branches: [master]
paths-ignore:
- "README.md"
- "docs/**"
jobs:
all-cli-checks:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/nextjs-app
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Set environment variables
run: mv .env.example .env
- name: Install dependencies
run: yarn install
- name: Build application
run: yarn build
- name: Run tests
run: yarn test
- name: Run linter
run: yarn lint
- name: Check types
run: yarn check-types
e2e:
timeout-minutes: 60
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/nextjs-app
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Set environment variables
run: mv .env.example-e2e .env
- name: Install dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn test-e2e
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: |
playwright-report/
mocked-db.json
retention-days: 30
name: Next.js App CI

on:
pull_request:
branches: [master]
paths: [apps/nextjs-app/**]

jobs:
build:
runs-on: ubuntu-latest

steps:
# Copy the repository to the virtual machine
- name: Checkout code
uses: actions/checkout@v3

# Install pnpm as package manager
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9

# Install dependencies
- name: Install dependencies
run: pnpm install:nextjs-app

# Run next build in app/nextjs-app directory
- name: Build static files
env:
NEXT_PUBLIC_API_URL: http://localhost:8082/api
NEXT_PUBLIC_ENABLE_API_MOCKING: false
NEXT_PUBLIC_MOCK_API_PORT: 8082
NEXT_PUBLIC_URL: http://localhost:3002
run: pnpm build:nextjs-app

test:
runs-on: ubuntu-latest

steps:
# Copy the repository to the virtual machine
- name: Checkout code
uses: actions/checkout@v3

# Install pnpm as package manager
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9

# Install dependencies
- name: Install dependencies
run: pnpm install:nextjs-app

# Run next test in app/nextjs-app directory
- name: Running test
env:
NEXT_PUBLIC_API_URL: http://localhost:8082/api
NEXT_PUBLIC_ENABLE_API_MOCKING: false
NEXT_PUBLIC_MOCK_API_PORT: 8082
NEXT_PUBLIC_URL: http://localhost:3002
run: pnpm test:nextjs-app

- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: vitest-reports
path: apps/nextjs-app/test-reports/

lint:
runs-on: ubuntu-latest

steps:
# Copy the repository to the virtual machine
- name: Checkout code
uses: actions/checkout@v3

# Install pnpm as package manager
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9

# Install dependencies
- name: Install dependencies
run: pnpm install:nextjs-app
# Run next test in app/nextjs-app directory
- name: Running code quality check
env:
NEXT_PUBLIC_API_URL: http://localhost:8082/api
NEXT_PUBLIC_ENABLE_API_MOCKING: false
NEXT_PUBLIC_MOCK_API_PORT: 8082
NEXT_PUBLIC_URL: http://localhost:3002
run: pnpm lint:nextjs-app

deploy:
runs-on: ubuntu-latest
needs: [test, build, lint]
steps:
# Copy the repository to the virtual machine
- name: Checkout code
uses: actions/checkout@v3

# Install dependencies
- name: Setup docker
uses: docker/setup-qemu-action@v3

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

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

- name: Build docker container
working-directory: apps/nextjs-app/
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/nextjs-app:latest \
--build-arg NEXT_PUBLIC_API_URL=http://localhost:8082/api \
--build-arg NEXT_PUBLIC_ENABLE_API_MOCKING=false \
--build-arg NEXT_PUBLIC_MOCK_API_PORT=8082 \
--build-arg NEXT_PUBLIC_URL=http://localhost:3002 .

# Push docker image to docker hub
- name: Publish docker image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/nextjs-app:latest
190 changes: 128 additions & 62 deletions .github/workflows/nextjs-pages-ci.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,128 @@
name: Next.js Pages CI
on:
push:
branches: ["*"]
paths-ignore:
- "README.md"
- "docs/**"
pull_request:
branches: [master]
paths-ignore:
- "README.md"
- "docs/**"
jobs:
all-cli-checks:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/nextjs-pages
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Set environment variables
run: mv .env.example .env
- name: Install dependencies
run: yarn install
- name: Build application
run: yarn build
- name: Run tests
run: yarn test
- name: Run linter
run: yarn lint
- name: Check types
run: yarn check-types
e2e:
timeout-minutes: 60
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./apps/nextjs-pages
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Set environment variables
run: mv .env.example-e2e .env
- name: Install dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn test-e2e
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: |
playwright-report/
mocked-db.json
retention-days: 30
name: Next.js Pages CI

on:
pull_request:
branches: [master]
paths: [apps/nextjs-pages/**]

jobs:
build:
runs-on: ubuntu-latest

steps:
# Copy the repository to the virtual machine
- name: Checkout code
uses: actions/checkout@v3

# Install pnpm as package manager
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9

# Install dependencies
- name: Install dependencies
run: pnpm install:nextjs-pages

# Run next build in app/nextjs-pages directory
- name: Build static files
env:
NEXT_PUBLIC_API_URL: http://localhost:8081/api
NEXT_PUBLIC_ENABLE_API_MOCKING: false
NEXT_PUBLIC_MOCK_API_PORT: 8081
NEXT_PUBLIC_URL: http://localhost:3001
run: pnpm build:nextjs-pages

test:
runs-on: ubuntu-latest

steps:
# Copy the repository to the virtual machine
- name: Checkout code
uses: actions/checkout@v3

# Install pnpm as package manager
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9

# Install dependencies
- name: Install dependencies
run: pnpm install:nextjs-pages

# Run next test in app/nextjs-pages directory
- name: Running test
env:
NEXT_PUBLIC_API_URL: http://localhost:8081/api
NEXT_PUBLIC_ENABLE_API_MOCKING: false
NEXT_PUBLIC_MOCK_API_PORT: 8081
NEXT_PUBLIC_URL: http://localhost:3001
run: pnpm test:nextjs-pages

- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: vitest-reports
path: apps/nextjs-pages/test-reports/

lint:
runs-on: ubuntu-latest

steps:
# Copy the repository to the virtual machine
- name: Checkout code
uses: actions/checkout@v3

# Install pnpm as package manager
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9

# Install dependencies
- name: Install dependencies
run: pnpm install:nextjs-pages

# Run next test in app/nextjs-pages directory
- name: Running code quality check
env:
NEXT_PUBLIC_API_URL: http://localhost:8081/api
NEXT_PUBLIC_ENABLE_API_MOCKING: false
NEXT_PUBLIC_MOCK_API_PORT: 8081
NEXT_PUBLIC_URL: http://localhost:3001
run: pnpm lint:nextjs-pages

deploy:
runs-on: ubuntu-latest
needs: [test, build, lint]
steps:
# Copy the repository to the virtual machine
- name: Checkout code
uses: actions/checkout@v3

# Install dependencies
- name: Setup docker
uses: docker/setup-qemu-action@v3

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

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

- name: Build docker container
working-directory: apps/nextjs-pages/
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/nextjs-pages:latest \
--build-arg NEXT_PUBLIC_API_URL=http://localhost:8081/api \
--build-arg NEXT_PUBLIC_ENABLE_API_MOCKING=false \
--build-arg NEXT_PUBLIC_MOCK_API_PORT=8081 \
--build-arg NEXT_PUBLIC_URL=http://localhost:3001 .

# Push docker image to docker hub
- name: Publish docker image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/nextjs-pages:latest
Loading