Skip to content

Commit

Permalink
Merge branch 'hngprojects:dev' into fix/add-hng-test-route-for-backends
Browse files Browse the repository at this point in the history
  • Loading branch information
elitenoire authored Jul 28, 2024
2 parents 63555f8 + 17298bf commit 678d0d6
Show file tree
Hide file tree
Showing 20 changed files with 588 additions and 198 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and Push

on:
push:
branches:
- dev

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
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 and push
uses: docker/build-push-action@v6
with:
file: docker/development/Dockerfile
push: true
tags: hngdevops/nextjs-boilerplate:dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Build, Lint, and Test
name: Build, Lint and Test

on:
pull_request
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: Coverage Report

on:
workflow_run:
workflows: ["CI Build, Lint, and Test"]
workflows: ["build-lint-test"]
types:
- completed

jobs:
report-test:
coverage_report:
runs-on: ubuntu-latest

permissions:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/dev-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Dev Deployment

on:
push:
branches:
- dev
paths-ignore:
- .github/workflows/**
workflow_run:
workflows: ["Build and Push"]
types:
- completed

jobs:
deploy_to_dev:
Expand Down
118 changes: 105 additions & 13 deletions .github/workflows/team-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,122 @@
name: Team Deployment

on:
push:
branches:
- team-deploy
paths-ignore:
- .github/workflows/**
workflow_run:
workflows: ["Build and Push"]
types:
- completed

jobs:
team_deployment:
kimiko-golang:
if: github.event.repository.fork == false
runs-on: ubuntu-latest
strategy:
matrix:
environment: [kimiko, cyborgs, starlight]

environment:
name: ${{ matrix.environment }}
url: ${{ secrets.URL }}
name: "kimiko-golang"
url: ${{ vars.URL }}

steps:
- name: Deploy to ${{ matrix.environment }} environment
- name: Deploy to kimiko-golang environment
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
./deploy_${{ matrix.environment }}.sh
cd hng_boilerplate_nextjs
./scripts/team_deploy.sh kimiko-golang ${{ vars.PORT }}
cyborgs-java:
if: github.event.repository.fork == false
runs-on: ubuntu-latest

environment:
name: "cyborgs-java"
url: ${{ vars.URL }}

steps:
- name: Deploy to cyborgs-java environment
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd hng_boilerplate_nextjs
./scripts/team_deploy.sh cyborgs-java ${{ vars.PORT }}
cyborgs-python:
if: github.event.repository.fork == false
runs-on: ubuntu-latest

environment:
name: "cyborgs-python"
url: ${{ vars.URL }}

steps:
- name: Deploy to cyborgs-python environment
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd hng_boilerplate_nextjs
./scripts/team_deploy.sh cyborgs-python ${{ vars.PORT }}
bulldozer-php:
if: github.event.repository.fork == false
runs-on: ubuntu-latest

environment:
name: "bulldozer-php"
url: ${{ vars.URL }}

steps:
- name: Deploy to bulldozer-php environment
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd hng_boilerplate_nextjs
./scripts/team_deploy.sh bulldozer-php ${{ vars.PORT }}
starlight-nestjs:
if: github.event.repository.fork == false
runs-on: ubuntu-latest

environment:
name: "starlight-nestjs"
url: ${{ vars.URL }}

steps:
- name: Deploy to starlight-nestjs environment
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd hng_boilerplate_nextjs
./scripts/team_deploy.sh starlight-nestjs ${{ vars.PORT }}
panther-expressjs:
if: github.event.repository.fork == false
runs-on: ubuntu-latest

environment:
name: "panther-expressjs"
url: ${{ vars.URL }}

steps:
- name: Deploy to panther-expressjs environment
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd hng_boilerplate_nextjs
./scripts/team_deploy.sh panther-expressjs ${{ vars.PORT }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand All @@ -37,4 +38,4 @@ yarn-error.log*
next-env.d.ts

# react email
/.react-email
/.react-email
23 changes: 23 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Security Policy

Security is very important for this project and its community. 🔒

Learn more about it below. 👇

## Versions

The latest version or release is supported.

You are encouraged to write tests for your application and update your versions frequently after ensuring that your tests are passing. This way you will benefit from the latest features, bug fixes, and **security fixes**.

## Reporting a Vulnerability

If you think you found a vulnerability, and even if you are not sure about it, please report it right away by sending an email to: [email protected]. Please try to be as explicit as possible, describing all the steps and example code to reproduce the security issue.

The maintainers will review it thoroughly and get back to you.

## Public Discussions

Please refrain from publicly discussing a potential security vulnerability. 🙊

It's better to discuss privately and try to find a solution first, to limit the potential impact as much as possible.
23 changes: 23 additions & 0 deletions scripts/dev_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 {next|remix}"
exit 1
fi

if [ "$1" == "next" ]; then
cd /home/nextjs/dev/hng_boilerplate_nextjs
git pull origin dev
docker compose -f docker/development/docker-compose.yml build
docker compose -f docker/development/docker-compose.yml up -d
elif [ "$1" == "remix" ]; then
cd /home/remixjs/dev/hng_boilerplate_remix
git pull origin dev
docker compose -f docker/development/docker-compose.yml build
docker compose -f docker/development/docker-compose.yml up -d
else
echo "Invalid argument. Use 'next' or 'remix'."
echo "Usage: $0 {next|remix}"
exit 1
fi

22 changes: 22 additions & 0 deletions scripts/prod_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 {next|remix}"
exit 1
fi

if [ "$1" == "next" ]; then
cd /home/nextjs/prod/hng_boilerplate_nextjs
git pull origin main
docker compose -f docker/prod/docker-compose.yml build
docker compose -f docker/prod/docker-compose.yml up -d
elif [ "$1" == "remix" ]; then
cd /home/remixjs/prod/hng_boilerplate_remix
git pull origin main
docker compose -f docker/prod/docker-compose.yml build
docker compose -f docker/prod/docker-compose.yml up -d
else
echo "Invalid argument. Use 'next' or 'remix'."
echo "Usage: $0 {next|remix}"
exit 1
fi
22 changes: 22 additions & 0 deletions scripts/staging_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 {next|remix}"
exit 1
fi

if [ "$1" == "next" ]; then
cd /home/nextjs/staging/hng_boilerplate_nextjs
git pull origin staging
docker compose -f docker/staging/docker-compose.yml build
docker compose -f docker/staging/docker-compose.yml up -d
elif [ "$1" == "remix" ]; then
cd /home/remixjs/staging/hng_boilerplate_remix
git pull origin staging
docker compose -f docker/staging/docker-compose.yml build
docker compose -f docker/staging/docker-compose.yml up -d
else
echo "Invalid argument. Use 'next' or 'remix'."
echo "Usage: $0 {next|remix}"
exit 1
fi
27 changes: 27 additions & 0 deletions scripts/team_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -e

# Check if the team name is provided
if [ -z "$1" ]; then
echo "Error: Team name is required."
echo "Usage: $0 [team name] [port]"
exit 1
fi

# Check if the port is provided
if [ -z "$2" ]; then
echo "Error: Port number is required."
echo "Usage: $0 [team name] [port]"
exit 1
fi

# Assign arguments to variables for clarity
TEAM_NAME=$1
PORT=$2

git pull origin dev
docker pull hngdevops/nextjs-boilerplate:dev
docker stop $TEAM_NAME || true
docker rm $TEAM_NAME -f || true
docker run -d --name "$TEAM_NAME" -p "$PORT:3000" hngdevops/nextjs-boilerplate:dev
Loading

0 comments on commit 678d0d6

Please sign in to comment.