- Add scripts/validate_commit_msg.py with conventional commit enforcement - Add scripts/configure_repo.py for Gitea branch protection and labels - Add scripts/__init__.py for Python package importability - Create Gitea Actions workflows: ci, auto-merge, post-merge, publish - Update .pre-commit-config.yaml with commit-msg hook - Update pyproject.toml pythonpath and coverage for scripts - Add comprehensive unit tests for both scripts with 100% coverage
68 lines
2.3 KiB
YAML
68 lines
2.3 KiB
YAML
name: Post-merge Vikunja update
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
vikunja:
|
|
runs-on: docker
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Update Vikunja task
|
|
env:
|
|
VIKUNJA_TOKEN: ${{ secrets.VIKUNJA_TOKEN }}
|
|
run: |
|
|
MERGE_MSG=$(git log -1 --pretty=%B)
|
|
TASK_ID=$(echo "$MERGE_MSG" | grep -oE 'GRM-[0-9]+' | head -1)
|
|
|
|
if [ -z "$TASK_ID" ]; then
|
|
echo "No task ID in commit message, skipping Vikunja update."
|
|
exit 0
|
|
fi
|
|
|
|
# Resolve GRM-N identifier to Vikunja numeric task ID.
|
|
# Vikunja's filter API does not support filtering by 'identifier' field,
|
|
# so we list all tasks and filter client-side by project_id=6 and identifier.
|
|
VIKUNJA_TASK_ID=$(curl -s \
|
|
"https://work.oblachno.oblachno.fyi/api/v1/tasks/all?per_page=50" \
|
|
-H "Authorization: Bearer ${VIKUNJA_TOKEN}" | \
|
|
python3 -c "
|
|
import sys, json
|
|
tasks = json.load(sys.stdin)
|
|
matches = [t for t in tasks if t.get('project_id') == 6 and t.get('identifier') == '${TASK_ID}']
|
|
print(matches[0]['id'] if matches else '')
|
|
")
|
|
|
|
if [ -z "$VIKUNJA_TASK_ID" ]; then
|
|
echo "ERROR: Could not find Vikunja task for ${TASK_ID} in project 6"
|
|
exit 1
|
|
fi
|
|
|
|
CONV_MSG=$(echo "$MERGE_MSG" | head -1 | sed -E 's/^GRM-[0-9]+: //')
|
|
COMMIT_SHA=$(git rev-parse HEAD)
|
|
|
|
# Post HTML comment to Vikunja
|
|
python3 -c "
|
|
import json, os
|
|
html = '<p><strong>${TASK_ID}</strong>: ${CONV_MSG}</p><p>Commit: <code>${COMMIT_SHA}</code></p>'
|
|
print(json.dumps({'content': html}))
|
|
" > /tmp/vikunja_comment.json
|
|
|
|
curl -X POST \
|
|
"https://work.oblachno.oblachno.fyi/api/v1/tasks/${VIKUNJA_TASK_ID}/comments" \
|
|
-H "Authorization: Bearer ${VIKUNJA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d @/tmp/vikunja_comment.json
|
|
|
|
# Mark task as done
|
|
curl -X PUT \
|
|
"https://work.oblachno.oblachno.fyi/api/v1/tasks/${VIKUNJA_TASK_ID}" \
|
|
-H "Authorization: Bearer ${VIKUNJA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"done": true}'
|
|
|
|
echo "Vikunja task ${TASK_ID} (ID ${VIKUNJA_TASK_ID}) updated and marked done."
|