Skip to content

Commit

Permalink
Merging to prod (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexindevs authored Aug 29, 2024
2 parents 478ff0a + f2da8a3 commit e598f53
Show file tree
Hide file tree
Showing 716 changed files with 57,385 additions and 1,487 deletions.
38 changes: 32 additions & 6 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
#!/bin/bash

REGEX="^((Merge[ a-z-]* branch.*)|(Revert*)|((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?!?: .*))"
# Regex to validate the type pattern
REGEX="^((Merge[ a-z-]* branch.*)|(Revert.*)|((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?!?: .*))"

# Check if a file argument was provided
if [ -z "$1" ]; then
echo >&2 "ERROR: No commit message file provided."
exit 1
fi

# Read the commit message from the file passed as an argument
FILE=$(cat "$1")

FILE=$(cat $1)
echo "Commit Message: ${FILE}"

if ! [[ $FILE =~ $REGEX ]]; then
echo >&2 "ERROR: Commit aborted for not following the Conventional Commit standard.​"
if [[ ! $FILE =~ $REGEX ]]; then
echo >&2 "ERROR: Commit aborted for not following the Conventional Commit standard."

# Check if the message is missing a valid type
if ! [[ $FILE =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?!?: ]]; then
echo >&2 "Hint: Commit message must start with one of the following types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test."
fi

# Check if the message is missing the scope (optional) and subject
if [[ ! $FILE =~ ^((build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?!?: ) ]]; then
echo >&2 "Hint: Commit message must follow the pattern 'type(scope): subject'. The scope is optional."
fi

# Check if the message is missing the colon and space after type (and scope)
if [[ $FILE =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?[^:]*$ ]]; then
echo >&2 "Hint: Commit message must include a colon and space after the type (and scope if present)."
fi

exit 1
else
echo >&2 "Valid commit message."
fi
echo "Valid commit message."
fi

Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
name: Build and Test
name: CI Build, Lint, and Test

on:
pull_request

jobs:
test:
build_lint_test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x' # Use the version of .NET you need
dotnet-version: '8.0.x'

- name: Install dependencies
run: |
dotnet restore ./Hng.Csharp.Web.sln
- name: Check Code Formatting
run: |
dotnet format ./Hng.Csharp.Web.sln --verify-no-changes --no-restore
- name: Build Application
run: |
dotnet build --configuration Release
dotnet build --configuration Release --no-restore
- name: Run Unit Tests
run: |
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/dev-deploy.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/dev-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Dev Deployment

on:
workflow_dispatch:
push:
branches:
- dev

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build Docker image
run: docker build -t csharp_dev .

- name: Save and compress Docker image
run: docker save csharp_dev | gzip > csharp_dev.tar.gz

- name: Upload Docker image
uses: actions/upload-artifact@v2
with:
name: csharp_dev
path: csharp_dev.tar.gz

deploy:
needs: build
if: github.event.repository.fork == false
runs-on: ubuntu-latest

environment:
name: "dev"
url: ${{ vars.URL }}

steps:
- name: Download Docker image
uses: actions/download-artifact@v2
with:
name: csharp_dev
path: .

- name: Copy image to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: csharp_dev.tar.gz
target: "/tmp"

- name: Deploy on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
gunzip -c /tmp/csharp_dev.tar.gz | docker load
rm -f /tmp/csharp_dev.tar.gz
cd ~/hng_boilerplate_csharp_web
docker compose -p csharp_dev up -d
28 changes: 0 additions & 28 deletions .github/workflows/prod-deploy.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/production-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Production Deployment

on:
workflow_dispatch:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build Docker image
run: docker build -t csharp_prod .

- name: Save and compress Docker image
run: docker save csharp_prod | gzip > csharp_prod.tar.gz

- name: Upload Docker image
uses: actions/upload-artifact@v2
with:
name: csharp_prod
path: csharp_prod.tar.gz

deploy:
needs: build
if: github.event.repository.fork == false
runs-on: ubuntu-latest

environment:
name: "production"
url: ${{ vars.URL }}

steps:
- name: Download Docker image
uses: actions/download-artifact@v2
with:
name: csharp_prod
path: .

- name: Copy image to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: csharp_prod.tar.gz
target: "/tmp"

- name: Deploy on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
gunzip -c /tmp/csharp_prod.tar.gz | docker load
rm -f /tmp/csharp_prod.tar.gz
cd ~/hng_boilerplate_csharp_web
docker compose -p csharp_prod -f docker-compose.prod.yml up -d
28 changes: 0 additions & 28 deletions .github/workflows/staging-deploy.yml

This file was deleted.

62 changes: 62 additions & 0 deletions .github/workflows/staging-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Staging Deployment

on:
workflow_dispatch:
push:
branches:
- staging

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Build Docker image
run: docker build -t csharp_staging .

- name: Save and compress Docker image
run: docker save csharp_staging | gzip > csharp_staging.tar.gz

- name: Upload Docker image
uses: actions/upload-artifact@v2
with:
name: csharp_staging
path: csharp_staging.tar.gz

deploy:
needs: build
if: github.event.repository.fork == false
runs-on: ubuntu-latest

environment:
name: "staging"
url: ${{ vars.URL }}

steps:
- name: Download Docker image
uses: actions/download-artifact@v2
with:
name: csharp_staging
path: .

- name: Copy image to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: csharp_staging.tar.gz
target: "/tmp"

- name: Deploy on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
gunzip -c /tmp/csharp_staging.tar.gz | docker load
rm -f /tmp/csharp_staging.tar.gz
cd ~/hng_boilerplate_csharp_web
docker compose -p csharp_staging -f docker-compose.staging.yml up -d
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,8 @@ src/Hng.Web/internal-nlog.txt
# AppSettings
appsettings.*.json

# Rider folder
.idea

#env files
.envrc
13 changes: 0 additions & 13 deletions .idea/.idea.Hng.Csharp.Web/.idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.idea.Hng.Csharp.Web/.idea/.name

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/.idea.Hng.Csharp.Web/.idea/encodings.xml

This file was deleted.

Loading

0 comments on commit e598f53

Please sign in to comment.