forked from bozp-pzob/digital-gardener
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (110 loc) · 4.68 KB
/
Copy pathelizaos.yml
File metadata and controls
129 lines (110 loc) · 4.68 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
name: Run ElizaOS Daily Task
on:
schedule:
- cron: '0 0 * * *' # Run at midnight UTC every day
workflow_dispatch: # Keep manual trigger option
jobs:
sqlite-job:
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
# Fetch existing DB from gh-pages branch if it exists
- name: Check and fetch database
run: |
mkdir -p data
# Check if gh-pages branch exists
if git ls-remote --heads origin gh-pages | grep -q gh-pages; then
echo "gh-pages branch exists, fetching database"
git fetch origin gh-pages:gh-pages || true
# Check if db.sqlite exists in the branch
if git ls-tree -r --name-only gh-pages | grep -q "data/db.sqlite"; then
git show gh-pages:data/db.sqlite > data/db.sqlite
echo "Restored database from gh-pages branch"
else
echo "No existing database found in gh-pages branch"
fi
else
echo "gh-pages branch does not exist yet, will be created on first deployment"
fi
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '23'
- name: Process secrets securely
run: |
echo '${{ secrets.ENV_SECRETS }}' > env_secrets.json
chmod 600 env_secrets.json
# Mask values
jq -r 'to_entries[] | .value' env_secrets.json | while read -r value; do
if [ -n "$value" ]; then
echo "::add-mask::$value"
fi
done
# Set environment variables
jq -r 'to_entries[] | select(.key != "TWITTER_COOKIES") | "\(.key)=\(.value)"' env_secrets.json > env_vars.txt
while IFS= read -r line; do
if [ -n "$line" ]; then
echo "$line" >> $GITHUB_ENV
fi
done < env_vars.txt
# Handle Twitter cookies specially
if jq -e '.TWITTER_COOKIES' env_secrets.json > /dev/null 2>&1; then
TWITTER_COOKIES=$(jq -r '.TWITTER_COOKIES' env_secrets.json)
{ echo "TWITTER_COOKIES<<EOF"; echo "$TWITTER_COOKIES"; echo "EOF"; } >> $GITHUB_ENV
fi
# Clean up
rm env_secrets.json env_vars.txt
- name: Install dependencies
run: npm install
- name: Get yesterday's date
id: date
run: echo "YESTERDAY=$(date -d "yesterday" +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Run historical with yesterday's date
run: npm run historical -- --source=elizaos.json --date=${{ steps.date.outputs.YESTERDAY }} --output=./output/elizaos
env:
RUN_ONCE: true
NODE_ENV: production
- name: Handle data files
run: |
# Create target directories
mkdir -p ./public/elizaos/json
mkdir -p ./public/elizaos/md
# Copy SQLite database
mkdir -p ./public/data
cp data/db.sqlite ./public/data/
# Copy output files
if [ -d "./output/elizaos/json" ] && [ "$(find ./output/elizaos/json -name "*2025-*-*.json" | wc -l)" -gt 0 ]; then
# Copy all JSON files
cp -r ./output/elizaos/json/* ./public/elizaos/json/
# Create daily.json symlink
LATEST_JSON=$(find ./output/elizaos/json -name "*2025-*-*.json" | sort -V | tail -n1)
LATEST_FILENAME=$(basename "$LATEST_JSON")
cp "$LATEST_JSON" ./public/elizaos/json/daily.json
echo "Copied $LATEST_JSON to daily.json"
else
echo "No JSON files found in ./output/elizaos/json directory"
echo '{"status":"no_data","date":"${{ steps.date.outputs.YESTERDAY }}"}' > ./public/elizaos/json/daily.json
fi
# Copy Markdown files
if [ -d "./output/elizaos/md" ]; then
cp -r ./output/elizaos/md/* ./public/elizaos/md/
fi
- name: Validate JSON files
run: find ./public -name "*.json" -type f -exec jq empty {} \; || { echo "Invalid JSON detected"; exit 1; }
# Deploy to gh-pages branch (default) from clean directory
- name: Deploy to gh-pages branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
force_orphan: false
keep_files: true