Skip to content

Scheduled Tasks

Scheduled Tasks #134

Workflow file for this run

name: Scheduled Tasks
on:
schedule:
- cron: '0 0 1 * *' # Midnight on 1st
- cron: '0 0 * * *' # Daily midnight
workflow_dispatch:
inputs:
job_to_run:
description: 'Which job to run'
required: true
type: choice
options:
- reset-tokens
- deploy-latest-server-version
- both
jobs:
reset-tokens:
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' &&
(
github.event.inputs.job_to_run == 'reset-tokens' ||
github.event.inputs.job_to_run == 'both'
)
||
(
github.event_name == 'schedule' &&
( ( startsWith(needs.date.outputs.day, '01') ) )
)
steps:
- name: Get Current Day
id: date
run: echo "day=$(date +'%d')" >> $GITHUB_OUTPUT
- name: Reset Tokens
run: |
curl -X GET \
-H "Authorization: Bearer ${{ secrets.CRON_SECRET }}" \
${{ secrets.VERCEL_URL }}/api/cron/reset-tokens
deploy-latest-server-version:
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' &&
(
github.event.inputs.job_to_run == 'deploy-latest-server-version' ||
github.event.inputs.job_to_run == 'both'
)
||
(
github.event_name == 'schedule' &&
! ( startsWith(needs.date.outputs.day, '01') )
)
steps:
- name: Get Current Day
id: date
run: echo "day=$(date +'%d')" >> $GITHUB_OUTPUT
- name: Deploy latest server version
run: |
curl -X GET \
-H "Authorization: Bearer ${{ secrets.CRON_SECRET }}" \
${{ secrets.VERCEL_URL }}/api/cron/redeploy