Backslaaaasshhh #41
This file contains 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: Fetch Kobo wishlist | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
schedule: | |
- cron: '0 12 * * *' # Noon UTC every day | |
push: | |
paths: | |
- '.github/workflows/cron-wishlist.yml' | |
- 'script/fetch-kobo-wishlist.ts' | |
env: | |
DENO_VERSION: v1.40.3 | |
READING_LIST_PATH: 'src/_data/reading_list.yml' | |
permissions: | |
contents: write # to checkout repo and write back log file | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
jobs: | |
fetch: | |
name: Fetch Kobo wishlist and sync | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Deno | |
uses: denoland/setup-deno@v1 | |
with: | |
deno-version: ${{ env.DENO_VERSION }} | |
- name: Fetch Kobo wishlist data | |
id: fetch | |
run: | | |
json=$(deno run --allow-net --allow-read --allow-env ./script/fetch-kobo-wishlist.ts) | |
if [[ -n "$json" ]]; then | |
echo "changes_made=true" >> $GITHUB_OUTPUT | |
echo "json<<EOF" >> $GITHUB_OUTPUT | |
echo "$json" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
else | |
echo "No new items to add" | |
echo "changes_made=false" >> $GITHUB_OUTPUT | |
fi | |
env: | |
reading_list: ${{ env.READING_LIST_PATH }} | |
KOBO_ACCESS_TOKEN: ${{ secrets.KOBO_ACCESS_TOKEN }} | |
KOBO_REFRESH_TOKEN: ${{ secrets.KOBO_REFRESH_TOKEN }} | |
- name: Post to Johan's API | |
if: steps.fetch.outputs.changes_made == 'true' | |
# Pull first, since something could've been pushed in-between. | |
run: | | |
curl -X POST \ | |
-H "API-Token $TOKEN" \ | |
-H "Content-Type: application/json" \ | |
-d '${{ steps.fetch.outputs.json }}' \ | |
https://johan-api.deno.dev | |
env: | |
TOKEN: ${{ secrets.JOHAN_API_ACTION_TOKEN }} |