-
Notifications
You must be signed in to change notification settings - Fork 82
69 lines (62 loc) · 2.56 KB
/
publish-discord-backup.yml
File metadata and controls
69 lines (62 loc) · 2.56 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
name: publish-discord-backup
on:
schedule:
- cron: "*/15 * * * *"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: publish-discord-backup
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout discrawl
uses: actions/checkout@v6.0.2
- name: Setup Go
uses: actions/setup-go@v6.3.0
with:
go-version-file: go.mod
cache: true
- name: Configure Git identity
run: |
git config --global user.name "discrawl publisher"
git config --global user.email "discrawl-publisher@users.noreply.github.com"
- name: Sync and publish Discord archive
env:
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_BACKUP_TOKEN: ${{ secrets.DISCORD_BACKUP_TOKEN }}
DISCRAWL_GUILD_ID: ${{ secrets.DISCRAWL_GUILD_ID }}
CONFIG: ${{ runner.temp }}/discrawl/config.toml
DB: ${{ runner.temp }}/discrawl/discrawl.db
BACKUP_REPO: ${{ runner.temp }}/discord-backup
run: |
if [ -z "${DISCORD_BOT_TOKEN:-}" ]; then
echo "::error title=Missing secret::Configure DISCORD_BOT_TOKEN in the discrawl repo secrets."
exit 1
fi
if [ -z "${DISCORD_BACKUP_TOKEN:-}" ]; then
echo "::error title=Missing secret::Configure DISCORD_BACKUP_TOKEN with write access to openclaw/discord-backup."
exit 1
fi
if [ -z "${DISCRAWL_GUILD_ID:-}" ]; then
echo "::error title=Missing secret::Configure DISCRAWL_GUILD_ID with the Discord guild to publish."
exit 1
fi
BACKUP_REMOTE="https://x-access-token:${DISCORD_BACKUP_TOKEN}@github.com/openclaw/discord-backup.git"
mkdir -p "$(dirname "$CONFIG")"
git clone "$BACKUP_REMOTE" "$BACKUP_REPO"
go run ./cmd/discrawl --config "$CONFIG" init --db "$DB" --guild "$DISCRAWL_GUILD_ID"
if [ -f "$BACKUP_REPO/manifest.json" ]; then
go run ./cmd/discrawl --config "$CONFIG" update --repo "$BACKUP_REPO" --remote "$BACKUP_REMOTE"
fi
go run ./cmd/discrawl --config "$CONFIG" sync --guild "$DISCRAWL_GUILD_ID" --skip-members --latest-only
git -C "$BACKUP_REPO" pull --ff-only origin main
go run ./cmd/discrawl --config "$CONFIG" publish \
--repo "$BACKUP_REPO" \
--remote "$BACKUP_REMOTE" \
--readme "$BACKUP_REPO/README.md" \
--message "sync: discord archive" \
--push