Post LeetCode PotD to Discord #392
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: Post LeetCode PotD to Discord | |
on: | |
schedule: | |
# Scheduled GitHub Actions seem to be consistently delayed... So this is | |
# a bit of a hack to kick off this workflow an hour early. If it runs | |
# before the new problem of the day is available, it will simply sleep | |
# until it is. And since we only post once per day thanks to the cache, | |
# this shouldn't result in any duplicate posts. | |
# See also: https://crontab.guru/ | |
- cron: 0 23 * * * | |
# Allows running this workflow manually from the repository's Actions tab. | |
workflow_dispatch: | |
# Allow only one concurrent run. Queueing additional runs should cancel any | |
# in-progress run so that the latest run is the one that gets priority. | |
concurrency: | |
group: post-leetcode-potd-to-discord | |
cancel-in-progress: true | |
jobs: | |
post-leetcode-potd-to-discord: | |
# Only run this job on the original repository! To run this on your fork, | |
# update or remove the line below. | |
if: github.repository == 'code-chronicles-code/leetcode-curriculum' | |
environment: | |
name: post-leetcode-potd-to-discord | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up everything | |
uses: ./.github/workflows/set-up-everything | |
- name: Prepare secrets | |
run: echo "$SECRETS_FILE" > workspaces/post-leetcode-potd-to-discord/secrets_DO_NOT_COMMIT_OR_SHARE.json | |
env: | |
SECRETS_FILE: ${{ secrets.SECRETS_FILE }} | |
- name: Prepare cached script data | |
uses: actions/cache@v4 | |
with: | |
path: workspaces/post-leetcode-potd-to-discord/data.json | |
restore-keys: post-leetcode-potd-to-discord-script-data- | |
# TODO: maybe label with the date instead of the run ID? | |
key: post-leetcode-potd-to-discord-script-data-${{ github.run_id }} | |
# TODO: maybe add `fail-on-cache-miss` when the job runs due to a cron | |
- name: Query problem of the day and post to Discord | |
run: yarn workspace @code-chronicles/post-leetcode-potd-to-discord start |