Files
grm/.gitea/workflows/auto-merge.yml
T
Emil Simeonov 3048d7ade7
CI / lint (push) Has been cancelled
CI / unit-tests (push) Has been cancelled
CI / molecule-tests (push) Has been cancelled
GRM-20: fix: enforce GRM-N: conventional on master commits and PR titles
2026-06-19 15:10:32 +02:00

40 lines
1.4 KiB
YAML

name: Auto-merge
on:
pull_request:
types: [labeled]
jobs:
merge:
if: github.event.label.name == 'ready-to-merge'
runs-on: docker
steps:
- name: Squash merge with task ID
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
BRANCH="${{ github.head_ref }}"
TASK_ID=$(echo "$BRANCH" | grep -oE 'GRM-[0-9]+' || echo "")
if [ -z "$TASK_ID" ]; then
echo "ERROR: No task ID (GRM-N) found in branch name '$BRANCH'"
exit 1
fi
PR_TITLE="${{ github.event.pull_request.title }}"
# Validate PR title follows conventional commits so squash merge message is valid
if ! echo "$PR_TITLE" | grep -qE '^(feat|fix|chore|docs|style|refactor|perf|test|ci|build|revert|BREAKING CHANGE)(\(.+\))?: .+'; then
echo "ERROR: PR title must follow conventional commit format."
echo " Expected: <type>: <description>"
echo " Got: $PR_TITLE"
exit 1
fi
MERGE_TITLE="${TASK_ID}: ${PR_TITLE}"
curl -X POST \
"https://git.oblachno.oblachno.fyi/api/v1/repos/${{ github.repository }}/pulls/${{ github.event.number }}/merge" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"Do\": \"squash\", \"MergeTitleField\": \"${MERGE_TITLE}\"}"