Files
Orchestrator/privat/andreknie-privat/OrgMyLife/sync-template.yml

47 lines
1.6 KiB
YAML

# Copy this file to .github/workflows/sync-to-orgmylife.yml in any repo
# Then add these secrets: ORGMYLIFE_USER, ORGMYLIFE_PASS, ORGMYLIFE_API_SECRET
#
# It reads PLAN.md for unchecked items (- [ ] ...) and syncs them to OrgMyLife
name: Sync Tasks to OrgMyLife
on:
push:
paths: ['PLAN.md', 'TASKS.md', 'BACKLOG.md']
workflow_dispatch: {}
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Parse open tasks and sync to OrgMyLife
run: |
REPO_NAME="${{ github.event.repository.name }}"
# Find open tasks from PLAN.md, TASKS.md, or BACKLOG.md
TASKS="[]"
for file in PLAN.md TASKS.md BACKLOG.md; do
if [ -f "$file" ]; then
# Extract unchecked items: "- [ ] Some task"
ITEMS=$(grep -E '^\s*- \[ \]' "$file" | sed 's/.*- \[ \] //' | head -50)
if [ -n "$ITEMS" ]; then
TASKS=$(echo "$ITEMS" | jq -R -s 'split("\n") | map(select(length > 0)) | map({"title": ., "status": "backlog"})')
break
fi
fi
done
echo "Found tasks: $TASKS"
# Sync to OrgMyLife
PAYLOAD=$(jq -n --arg repo "$REPO_NAME" --argjson tasks "$TASKS" '{"repo": $repo, "tasks": $tasks}')
curl -s -X POST \
-u "${{ secrets.ORGMYLIFE_USER }}:${{ secrets.ORGMYLIFE_PASS }}" \
-H "X-API-Key: ${{ secrets.ORGMYLIFE_API_SECRET }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
"https://api.andreknie.de/api/projects/sync"