chore: setup commitlint and git hooks
Some checks failed
Commit Message Check / conventional-commits (pull_request) Failing after 6s
Deploy monie-backend to dev (kaniko) / build-and-deploy (pull_request) Successful in 0s
Deploy monie-backend (kaniko) / build-and-deploy (pull_request) Successful in 0s

This commit is contained in:
2026-04-03 19:34:33 +03:00
parent 508bbdf5cc
commit 18f167418d
7 changed files with 108 additions and 4 deletions

View File

@@ -0,0 +1,69 @@
name: Commit Message Check
on:
push:
branches: [ main, develop ]
pull_request:
jobs:
conventional-commits:
runs-on: [self-hosted, linux]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Validate commit messages with commitlint
env:
EVENT_NAME: ${{ github.event_name }}
BEFORE_SHA: ${{ github.event.before }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
HEAD_SHA: ${{ github.sha }}
run: |
set -euo pipefail
BASE_SHA=""
TARGET_SHA="${HEAD_SHA}"
BASE_HINT_SHA="${PR_BASE_SHA:-}"
if [ "${EVENT_NAME}" = "pull_request" ]; then
if [ -n "${PR_HEAD_SHA:-}" ]; then
TARGET_SHA="${PR_HEAD_SHA}"
elif git rev-parse "${HEAD_SHA}^2" >/dev/null 2>&1; then
TARGET_SHA="$(git rev-parse "${HEAD_SHA}^2")"
fi
if [ -z "${BASE_HINT_SHA}" ] && git rev-parse "${HEAD_SHA}^1" >/dev/null 2>&1; then
BASE_HINT_SHA="$(git rev-parse "${HEAD_SHA}^1")"
fi
fi
if [ "${EVENT_NAME}" = "pull_request" ] && [ -n "${BASE_HINT_SHA}" ] && [ -n "${TARGET_SHA:-}" ]; then
BASE_SHA="$(git merge-base "${BASE_HINT_SHA}" "${TARGET_SHA}" || true)"
if [ -z "${BASE_SHA}" ]; then
BASE_SHA="${BASE_HINT_SHA}"
fi
elif [ -n "${BEFORE_SHA:-}" ] && [ "${BEFORE_SHA}" != "0000000000000000000000000000000000000000" ]; then
BASE_SHA="${BEFORE_SHA}"
elif git rev-parse "${TARGET_SHA}^" >/dev/null 2>&1; then
BASE_SHA="$(git rev-parse "${TARGET_SHA}^")"
fi
if [ -n "${BASE_SHA}" ] && [ "${BASE_SHA}" != "${TARGET_SHA}" ]; then
npx --no -- commitlint --from "${BASE_SHA}" --to "${TARGET_SHA}" --verbose
else
git log -1 --format=%s "${TARGET_SHA}" | npx --no -- commitlint --verbose
fi

View File

@@ -3,6 +3,7 @@ name: Deploy monie-backend to dev (kaniko)
on:
push:
branches: [ develop ]
pull_request:
jobs:
build-and-deploy:
@@ -26,7 +27,12 @@ jobs:
REPO_PATH: monie/monie-backend.git
steps:
- name: Skip deploy for pull requests
if: github.event_name == 'pull_request'
run: echo "Pull request check passed. Deploy runs only on push to develop."
- name: Debug
if: github.event_name == 'push'
run: |
set -eu
echo "sha=${{ github.sha }}"
@@ -35,6 +41,7 @@ jobs:
microk8s kubectl version --client=true
- name: Build & push with Kaniko (K8s Job)
if: github.event_name == 'push'
env:
SHA: ${{ github.sha }}
REF: ${{ github.ref_name }}
@@ -131,6 +138,7 @@ jobs:
fi
- name: Deploy to dev
if: github.event_name == 'push'
env:
SHA: ${{ github.sha }}
run: |

View File

@@ -1,9 +1,9 @@
# .gitea/workflows/deploy-prod.yml
name: Deploy monie-backend (kaniko)
on:
push:
branches: [ main ]
pull_request:
jobs:
build-and-deploy:
@@ -27,7 +27,12 @@ jobs:
REPO_PATH: monie/monie-backend.git
steps:
- name: Skip deploy for pull requests
if: github.event_name == 'pull_request'
run: echo "Pull request check passed. Deploy runs only on push to main."
- name: Build & push image with Kaniko (K8s Job)
if: github.event_name == 'push'
env:
SHA: ${{ github.sha }}
REF: ${{ github.ref_name }}
@@ -120,6 +125,7 @@ jobs:
fi
- name: Deploy to prod
if: github.event_name == 'push'
env:
SHA: ${{ github.sha }}
run: |