summaryrefslogtreecommitdiff
path: root/official-site-scripts/add-event.sh
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-06-15 23:25:39 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-06-15 23:25:39 +0900
commit090cf7d92e8e660b1dccf8d64780bd2430660cbc (patch)
tree7d066972e89a47ca36f87e1faebec3366c8c8a94 /official-site-scripts/add-event.sh
parent0443c8c9972cbe792716cca193f7ad1ae64c0eda (diff)
Add official-site-2023-dev as git submodule at official-site/
- Move management scripts from official-site/ to official-site-scripts/ - Update CLAUDE.md paths accordingly - Deploy key configured at ~/.ssh/mosquitone_official_site_deploy with SSH alias github-mosquitone-official-site Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'official-site-scripts/add-event.sh')
-rwxr-xr-xofficial-site-scripts/add-event.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/official-site-scripts/add-event.sh b/official-site-scripts/add-event.sh
new file mode 100755
index 0000000..109c2c8
--- /dev/null
+++ b/official-site-scripts/add-event.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+# Usage: bash add-event.sh <json-file>
+# The JSON file should match the Event schema (see CLAUDE.md).
+# id, createdAt, updatedAt, _version, _deleted, _lastChangedAt are auto-managed.
+set -euo pipefail
+
+REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+[ -f "$REPO_ROOT/.env" ] && set -a && source "$REPO_ROOT/.env" && set +a
+
+ENDPOINT="${APP_SYNC_ENDPOINT:?APP_SYNC_ENDPOINT not set}"
+API_KEY="${APP_SYNC_API_KEY:?APP_SYNC_API_KEY not set}"
+
+JSON_FILE="${1:-}"
+if [ -z "$JSON_FILE" ]; then
+ echo "Usage: $0 <event-json-file>"
+ exit 1
+fi
+
+INPUT=$(python3 -c "
+import json, sys
+with open('$JSON_FILE') as f:
+ data = json.load(f)
+# Remove read-only / auto-managed fields
+for k in ['id', 'createdAt', 'updatedAt', '_version', '_deleted', '_lastChangedAt', '_note']:
+ data.pop(k, None)
+# Remove null fields (optional)
+data = {k: v for k, v in data.items() if v is not None}
+print(json.dumps(data))
+")
+
+QUERY='mutation CreateEvent($input: CreateEventInput!) { createEvent(input: $input) { id type date title venueName published } }'
+PAYLOAD=$(python3 -c "
+import json, sys
+q = '$QUERY'
+inp = $INPUT
+print(json.dumps({'query': q, 'variables': {'input': inp}}))
+")
+
+echo "Creating event from $JSON_FILE ..."
+RESULT=$(curl -s -X POST "$ENDPOINT" \
+ -H "Content-Type: application/json" \
+ -H "x-api-key: $API_KEY" \
+ -d "$PAYLOAD")
+
+echo "$RESULT" | python3 -m json.tool
+echo ""
+echo "Done. Run 'bash deploy.sh' to rebuild the site."