-
Notifications
You must be signed in to change notification settings - Fork 8
144 lines (123 loc) · 4.47 KB
/
manual-update-library.yml
File metadata and controls
144 lines (123 loc) · 4.47 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Manual Update System Prompt Library
on:
workflow_dispatch:
inputs:
update_type:
description: 'Type of update to perform'
required: true
default: 'full'
type: choice
options:
- full
- consolidate-only
- index-only
- readme-only
force_rebuild:
description: 'Force rebuild all files'
required: false
default: false
type: boolean
jobs:
update-library:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Show current status
run: |
echo "📊 Repository Status:"
echo "Current branch: $(git branch --show-current)"
echo "Last commit: $(git log -1 --oneline)"
echo ""
echo "📁 File counts:"
echo "JSON files: $(find system-prompts/json -name '*.json' 2>/dev/null | wc -l)"
echo "Consolidated file exists: $([ -f consolidated_prompts.json ] && echo 'Yes' || echo 'No')"
echo "Index file exists: $([ -f index.md ] && echo 'Yes' || echo 'No')"
- name: Run library update script
run: |
echo "🚀 Running update with parameters:"
echo "Update type: ${{ github.event.inputs.update_type }}"
echo "Force rebuild: ${{ github.event.inputs.force_rebuild }}"
echo ""
# Build command arguments
ARGS=""
if [ "${{ github.event.inputs.force_rebuild }}" = "true" ]; then
ARGS="$ARGS --force-rebuild"
fi
case "${{ github.event.inputs.update_type }}" in
"consolidate-only")
ARGS="$ARGS --consolidate-only"
;;
"index-only")
ARGS="$ARGS --index-only"
;;
"readme-only")
ARGS="$ARGS --readme-only"
;;
"full")
# No additional args needed for full update
;;
esac
echo "Command: python3 update_library_unified.py $ARGS"
python3 update_library_unified.py $ARGS
- name: Show update results
run: |
echo "📈 Update Results:"
if [ -f consolidated_prompts.metadata.json ]; then
echo "Consolidated metadata:"
cat consolidated_prompts.metadata.json | python3 -m json.tool
fi
echo ""
if [ -f index_metadata.json ]; then
echo "Index metadata:"
cat index_metadata.json | python3 -m json.tool
fi
- name: Check for changes
id: verify-changed-files
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "✅ Changes detected:"
git status --short
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "ℹ️ No changes detected"
fi
- name: Commit and push changes
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git add .
# Create detailed commit message
COMMIT_MSG="🔧 Manual library update (${{ github.event.inputs.update_type }}): $(date '+%Y-%m-%d %H:%M UTC')"
if [ -f consolidated_prompts.metadata.json ]; then
VALID_PROMPTS=$(cat consolidated_prompts.metadata.json | python3 -c "import sys, json; data=json.load(sys.stdin); print(data['stats']['valid_prompts'])" 2>/dev/null || echo "unknown")
COMMIT_MSG="$COMMIT_MSG
📊 Stats: $VALID_PROMPTS valid prompts processed"
fi
COMMIT_MSG="$COMMIT_MSG
🔄 Update type: ${{ github.event.inputs.update_type }}
🔨 Force rebuild: ${{ github.event.inputs.force_rebuild }}
Triggered manually via GitHub Actions"
git commit -m "$COMMIT_MSG"
git push
- name: Summary
run: |
echo "🎯 Workflow Summary:"
echo "Update type: ${{ github.event.inputs.update_type }}"
echo "Force rebuild: ${{ github.event.inputs.force_rebuild }}"
if [ "${{ steps.verify-changed-files.outputs.changed }}" = "true" ]; then
echo "Result: ✅ Changes committed and pushed"
else
echo "Result: ℹ️ No changes needed"
fi