forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (52 loc) · 2.13 KB
/
Copy pathsync-question-answers.yml
File metadata and controls
60 lines (52 loc) · 2.13 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
name: Sync Question Answers
# PRD ⑤ §9: close the answer-delivery loop — copies answered/pending question
# intakes from GitHub issues into the D1 `questions` table (durable state that
# the worker's re-submission pull and search FAQ merge read from).
# Script: scripts/sync_answered_questions.py
on:
schedule:
- cron: '20 7 * * *' # Daily 07:20 UTC
issues:
types: [labeled, closed]
workflow_dispatch:
inputs:
issue:
description: "Specific issue number to sync"
required: false
type: string
concurrency:
group: sync-question-answers-${{ github.event.issue.number || 'all' }}
cancel-in-progress: false
permissions:
contents: read
jobs:
sync:
# Trigger on:
# 1. Scheduled daily cron
# 2. Manual workflow_dispatch
# 3. 'labeled' event when label is 'answered'
# 4. 'closed' event when issue has 'answered' label
if: >-
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issues' && github.event.action == 'labeled' && github.event.label.name == 'answered') ||
(github.event_name == 'issues' && github.event.action == 'closed' && contains(github.event.issue.labels.*.name, 'answered'))
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: 6b92325b505f2b76aec49e9fe4195d31
steps:
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Sync single question answer to D1
if: github.event_name == 'issues' || (github.event_name == 'workflow_dispatch' && inputs.issue != '')
run: |
ISSUE_NUM="${{ github.event.issue.number || inputs.issue }}"
python3 scripts/sync_answered_questions.py --issue "$ISSUE_NUM"
- name: Sync all question answers to D1 (batch/cron)
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && (inputs.issue == '' || inputs.issue == null))
run: python3 scripts/sync_answered_questions.py