-
Notifications
You must be signed in to change notification settings - Fork 8
74 lines (69 loc) · 2.97 KB
/
Copy pathsync-issues-prs-to-lovable.yml
File metadata and controls
74 lines (69 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Sync GitHub Issues and PRs to Lovable (main project)
# Repo: asperpharma/understand-project
# Lovable: https://lovable.dev/projects/657fb572-13a5-4a3e-bac9-184d39fdf7e6
#
# Sends issue/PR open, edit, reopen, close events to Lovable via webhook.
#
# REQUIRED SETUP:
# 1. In GitHub repo → Settings → Secrets and variables → Actions
# 2. Add secret: LOVABLE_WEBHOOK_URL = (webhook URL from Lovable)
# 3. See docs/GITHUB_SECRETS_SETUP.md for detailed instructions
#
# This workflow will FAIL if LOVABLE_WEBHOOK_URL is not configured.
#
name: Sync Issues and PRs to Lovable
on:
issues:
types: [opened, edited, closed, reopened]
pull_request:
types: [opened, edited, reopened, closed]
jobs:
sync_to_lovable:
runs-on: ubuntu-latest
# Skip this job if LOVABLE_WEBHOOK_URL is not configured
if: secrets.LOVABLE_WEBHOOK_URL != ''
steps:
- name: Send event data to Lovable
env:
LOVABLE_WEBHOOK_URL: ${{ secrets.LOVABLE_WEBHOOK_URL }}
run: |
# Skip gracefully when LOVABLE_WEBHOOK_URL is not configured
if [ -z "$LOVABLE_WEBHOOK_URL" ]; then
echo "Warning: LOVABLE_WEBHOOK_URL is not set"
echo "Please set the LOVABLE_WEBHOOK_URL secret in the repository settings to enable sync."
echo "Skipping Lovable sync (secret not configured)."
exit 0
fi
# Validate URL format
if ! echo "$LOVABLE_WEBHOOK_URL" | grep -qE '^https?://'; then
echo "Warning: LOVABLE_WEBHOOK_URL does not appear to be a valid URL"
echo "Expected format: https://api.lovable.ai/... or similar"
echo "Skipping Lovable sync."
exit 0
fi
# Debug: Show masked URL (only show protocol and domain)
MASKED_URL=$(echo "$LOVABLE_WEBHOOK_URL" | sed -E 's|(https?://[^/]+).*|\1/...|')
echo "LOVABLE_WEBHOOK_URL=$MASKED_URL"
echo "Sending event to Lovable..."
# Use GitHub event path JSON directly to avoid shell injection issues
PAYLOAD=$(jq -n \
--arg event_name "${{ github.event_name }}" \
--arg action "${{ github.event.action }}" \
--arg repo "${{ github.repository }}" \
--arg sender "${{ github.actor }}" \
--arg url "${{ github.event.issue.html_url || github.event.pull_request.html_url }}" \
--argjson event_data "$(cat "$GITHUB_EVENT_PATH")" \
'{
event_name: $event_name,
action: $action,
repo: $repo,
sender: $sender,
url: $url,
title: ($event_data.issue.title // $event_data.pull_request.title // ""),
body: ($event_data.issue.body // $event_data.pull_request.body // "")
}'
)
curl -s -X POST "$LOVABLE_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" || echo "Warning: Lovable webhook call failed (non-fatal)."
echo "Done."