Skip to content

Sync Discord Roles #140

Sync Discord Roles

Sync Discord Roles #140

name: Sync Discord Roles
on:
schedule:
# GitHub Actions schedules are best-effort; avoid crowded :00/:15/:30/:45 slots.
- cron: '7,22,37,52 * * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
environment: cron-job
steps:
- name: Trigger Discord Role Sync
run: |
response=$(curl -s -w "\n%{http_code}" -X POST \
-H "Content-Type: application/json" \
-H "X-Cron-Token: ${{ secrets.CRON_SYNC_TOKEN }}" \
"${{ secrets.API_BASE_URL }}/api/v1/users/discord/sync-roles/")
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
echo "Response: $body"
echo "HTTP Code: $http_code"
if [ "$http_code" = "200" ] || [ "$http_code" = "202" ]; then
echo "Discord role sync triggered successfully"
elif [ "$http_code" = "409" ]; then
echo "Discord role sync already in progress, skipping"
else
echo "Discord role sync failed with status $http_code"
exit 1
fi