publish-discord-backup #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| go run ./cmd/discrawl --config "$CONFIG" publish \ | |
| --repo "$BACKUP_REPO" \ | |
| --remote "$BACKUP_REMOTE" \ | |
| --readme "$BACKUP_REPO/README.md" \ | |
| --message "sync: discord archive" \ | |
| --push |