From 038aee0cbf667296709330928c0104144c4fe424 Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 19:57:19 -0500 Subject: [PATCH 01/15] Update README.md --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fa9b857..54a1a7c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,27 @@ -# wodaboard +# WODaboard + 💪 "Workout Of the Day" on Vestaboard +``` +touch .env +``` + +# Create a Vestaboard Installable/Subscription + +Use the web app's API tab to create an installable for your Vestaboard. +Once you have the subscription id, api key, and api secret, add them to your .env for running locally +or your GitHub action secrets for running with a GitHub workflow as a cron job. Be sure to keep your API keys secret and not commit them. ``` +# .env +VB_SUB_ID=yoursubscriptionid +VB_SUB_KEY=yoursubscriptionapikey +VB_SUB_SECRET=yoursubscriptionapisecret +``` + +``` +# send a wod to your Vestaboard bun run index.ts -``` \ No newline at end of file +``` + +You can find more information on Vestaboard subscriptions at https://docs.vestaboard.com. Happy hacking! From 5d81cc54823cfd56b4368de806f99413435f8bf6 Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 19:58:18 -0500 Subject: [PATCH 02/15] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 54a1a7c..44b9f04 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# WODaboard +# 💪 WODaboard 🏋️ -💪 "Workout Of the Day" on Vestaboard +"Workout Of the Day" on Vestaboard ``` touch .env @@ -20,7 +20,7 @@ VB_SUB_SECRET=yoursubscriptionapisecret ``` ``` -# send a wod to your Vestaboard +# send a WOD to your Vestaboard bun run index.ts ``` From ae571c86af7a460b53e886163d5e48b36c833eda Mon Sep 17 00:00:00 2001 From: John Ottenlips Date: Sat, 16 Sep 2023 20:46:07 -0500 Subject: [PATCH 03/15] =?UTF-8?q?mastodon=20integration=20=F0=9F=90=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +++++++- bun.lockb | Bin 3888 -> 3888 bytes index.ts | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 44b9f04..6193842 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # 💪 WODaboard 🏋️ -"Workout Of the Day" on Vestaboard +"Workout Of the Day" on Vestaboard + +This Github Action workflow also posts the Vestbaord message to the [workoutoftheday@mastodon.social](https://mastodon.social/@workoutoftheday). ``` touch .env @@ -17,10 +19,14 @@ or your GitHub action secrets for running with a GitHub workflow as a cron job. VB_SUB_ID=yoursubscriptionid VB_SUB_KEY=yoursubscriptionapikey VB_SUB_SECRET=yoursubscriptionapisecret + +# (optional to post to Mastodon) +MASTODON_ACCESS_TOKEN= ``` ``` # send a WOD to your Vestaboard +bun install bun run index.ts ``` diff --git a/bun.lockb b/bun.lockb index 7c1b196f95536a82c9537f675a7b92fc64571ce5..69863e7fb3a400bcc520088be9be8b81c5f410d7 100755 GIT binary patch delta 220 zcmdlWw?S@$1|v(h>m`=S0*o@O0_x1HjGKKKH?!7*#26V6pp%7xq2PsME=Y_IDojH$ eE#fViEXZiQ`3}1(dKVlRxALi%_GeK delta 200 zcmdlWw?S@$2IC|ajmZ-jIW|Wyu3(*9!zfVi!^*%=z@M1U$iTqB0>mIdM=>ef7Ek`j VY`pmnyD&356U14Yzj0Zy001|N8d?AV diff --git a/index.ts b/index.ts index 57996b9..24b481d 100644 --- a/index.ts +++ b/index.ts @@ -13,9 +13,16 @@ const days = { 5: "friday", 6: "saturday", } as { [key: number]: IDays }; -type IDays = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday"; +type IDays = + | "sunday" + | "monday" + | "tuesday" + | "wednesday" + | "thursday" + | "friday" + | "saturday"; -const main = () => { +const main = async () => { const day = new Date().getDay(); const dayName = days[day]; const intensity = day % 3 === 0 ? "hard" : day % 2 === 0 ? "medium" : "easy"; @@ -23,7 +30,8 @@ const main = () => { const color = day % 3 === 0 ? "{63}" : day % 2 === 0 ? "{65}" : "{66}"; const text = `${color}Happy ${dayName}!${color}\nToday's WOD is:\n${exercises}`; console.log(text); - sendMessage(text); + await sendMessage(text); + await sendMastodonMessage(text); }; const sendMessage = async (text: string) => { @@ -41,4 +49,25 @@ const sendMessage = async (text: string) => { } }; +const sendMastodonMessage = async (text: string) => { + const status = text + .replace("{66}", "🟩 ") + .replace("{66}", " 🟩") + .replace("{65}", "🟨 ") + .replace("{65}", " 🟨") + .replace("{63}", "🟥 ") + .replace("{63}", " 🟥"); + + if (process.env.MASTODON_ACCESS_TOKEN) { + await fetch(`https://mastodon.social/api/v1/statuses`, { + method: "POST", + headers: { + Authorization: `Bearer ${process.env.MASTODON_ACCESS_TOKEN}`, + "Idempotency-Key": `${Date.now()}`, + }, + body: `status=${encodeURIComponent(status)}`, + }); + } +}; + main(); From ed1f9a36692651a1ad7549a566e1306bed7031b9 Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 20:52:08 -0500 Subject: [PATCH 04/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6193842..31e261d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 💪 WODaboard 🏋️ -"Workout Of the Day" on Vestaboard +"Workout Of the Day" sent to a Vestaboard This Github Action workflow also posts the Vestbaord message to the [workoutoftheday@mastodon.social](https://mastodon.social/@workoutoftheday). From 9118fa09aaf4cb3f219a511020da2f71e8aefc6a Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 20:52:33 -0500 Subject: [PATCH 05/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31e261d..b5dcb74 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ "Workout Of the Day" sent to a Vestaboard -This Github Action workflow also posts the Vestbaord message to the [workoutoftheday@mastodon.social](https://mastodon.social/@workoutoftheday). +This Github Action workflow also posts the message to [workoutoftheday@mastodon.social](https://mastodon.social/@workoutoftheday). ``` touch .env From 6af620970b23c0b3bd815524b977fde7d6591814 Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 20:52:46 -0500 Subject: [PATCH 06/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b5dcb74..06d8a15 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This Github Action workflow also posts the message to [workoutoftheday@mastodon. touch .env ``` -# Create a Vestaboard Installable/Subscription +# Create your own Vestaboard Installable/Subscription Use the web app's API tab to create an installable for your Vestaboard. Once you have the subscription id, api key, and api secret, add them to your .env for running locally From f9035822699a6b99d72f3af9dc09162926ce253a Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 20:54:25 -0500 Subject: [PATCH 07/15] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 06d8a15..ca9da46 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,6 @@ This Github Action workflow also posts the message to [workoutoftheday@mastodon.social](https://mastodon.social/@workoutoftheday). -``` -touch .env -``` - # Create your own Vestaboard Installable/Subscription Use the web app's API tab to create an installable for your Vestaboard. From 6d5059a075aaec924dee6e5ba7cd811b99e58753 Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 20:55:45 -0500 Subject: [PATCH 08/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca9da46..e5eabab 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 💪 WODaboard 🏋️ -"Workout Of the Day" sent to a Vestaboard +"Workout Of the Day" sent to a Vestaboard. This is an example of how you can use the Vestaboard developer API to send messages to your Vestaboard. This Github Action workflow also posts the message to [workoutoftheday@mastodon.social](https://mastodon.social/@workoutoftheday). From 49e8d294c08fa7995052860163a0afabac72c9fa Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 20:59:45 -0500 Subject: [PATCH 09/15] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e5eabab..e7a3baf 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ This Github Action workflow also posts the message to [workoutoftheday@mastodon.social](https://mastodon.social/@workoutoftheday). +Disclaimer: These workouts are random and vary in intensity. I am not a personal trainer so seek professional advice before following my dummy data. + # Create your own Vestaboard Installable/Subscription Use the web app's API tab to create an installable for your Vestaboard. From a12664164ededcd69367bbeb1058fcb86463b81b Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 21:00:01 -0500 Subject: [PATCH 10/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7a3baf..b9759d3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This Github Action workflow also posts the message to [workoutoftheday@mastodon.social](https://mastodon.social/@workoutoftheday). -Disclaimer: These workouts are random and vary in intensity. I am not a personal trainer so seek professional advice before following my dummy data. +Disclaimer: These workouts are random and vary in intensity. I am not a personal trainer, so seek professional advice before following my dummy data. # Create your own Vestaboard Installable/Subscription From 06e6d7aa26195be7ab8f31f82bb3817ac23e3ac5 Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Sat, 16 Sep 2023 21:00:32 -0500 Subject: [PATCH 11/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b9759d3..a56298d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This Github Action workflow also posts the message to [workoutoftheday@mastodon.social](https://mastodon.social/@workoutoftheday). -Disclaimer: These workouts are random and vary in intensity. I am not a personal trainer, so seek professional advice before following my dummy data. +⚠️ Disclaimer: These workouts are random and vary in intensity. I am not a personal trainer, so seek professional advice before following my dummy data. # Create your own Vestaboard Installable/Subscription From e24bc307a6a416eba8ad5d33c758f60475742465 Mon Sep 17 00:00:00 2001 From: John Ottenlips Date: Sun, 17 Sep 2023 12:42:42 -0500 Subject: [PATCH 12/15] add mastodon token --- .github/workflows/wodaboard.yaml | 3 ++- index.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wodaboard.yaml b/.github/workflows/wodaboard.yaml index 209fd17..3ed1348 100644 --- a/.github/workflows/wodaboard.yaml +++ b/.github/workflows/wodaboard.yaml @@ -22,4 +22,5 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VB_SUB_ID: ${{ secrets.VB_SUB_ID }} VB_SUB_KEY: ${{ secrets.VB_SUB_KEY }} - VB_SUB_SECRET: ${{ secrets.VB_SUB_SECRET }} \ No newline at end of file + VB_SUB_SECRET: ${{ secrets.VB_SUB_SECRET }} + MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }} diff --git a/index.ts b/index.ts index 24b481d..4cc5b49 100644 --- a/index.ts +++ b/index.ts @@ -25,9 +25,10 @@ type IDays = const main = async () => { const day = new Date().getDay(); const dayName = days[day]; - const intensity = day % 3 === 0 ? "hard" : day % 2 === 0 ? "medium" : "easy"; + const intensity = day % 1 === 0 ? "hard" : day % 2 === 0 ? "medium" : "easy"; const exercises = randomFourExercises(intensity); - const color = day % 3 === 0 ? "{63}" : day % 2 === 0 ? "{65}" : "{66}"; + const color = + intensity === "hard" ? "{63}" : intensity === "medium" ? "{65}" : "{66}"; const text = `${color}Happy ${dayName}!${color}\nToday's WOD is:\n${exercises}`; console.log(text); await sendMessage(text); From a48326c61ca76d988555affe789ceafcfb790242 Mon Sep 17 00:00:00 2001 From: John Ottenlips Date: Sun, 17 Sep 2023 12:46:00 -0500 Subject: [PATCH 13/15] hashtag --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 4cc5b49..a9e68da 100644 --- a/index.ts +++ b/index.ts @@ -66,7 +66,7 @@ const sendMastodonMessage = async (text: string) => { Authorization: `Bearer ${process.env.MASTODON_ACCESS_TOKEN}`, "Idempotency-Key": `${Date.now()}`, }, - body: `status=${encodeURIComponent(status)}`, + body: `status=${encodeURIComponent(status + `\n#workoutoftheday`)}`, }); } }; From 868dbd9a03c852413ae1c8f65a1c8115f30e983c Mon Sep 17 00:00:00 2001 From: John Ottenlips Date: Sun, 17 Sep 2023 12:47:08 -0500 Subject: [PATCH 14/15] mod 3 --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index a9e68da..0311366 100644 --- a/index.ts +++ b/index.ts @@ -25,7 +25,7 @@ type IDays = const main = async () => { const day = new Date().getDay(); const dayName = days[day]; - const intensity = day % 1 === 0 ? "hard" : day % 2 === 0 ? "medium" : "easy"; + const intensity = day % 3 === 1 ? "hard" : day % 3 === 2 ? "medium" : "easy"; const exercises = randomFourExercises(intensity); const color = intensity === "hard" ? "{63}" : intensity === "medium" ? "{65}" : "{66}"; From 29541557f6bd0afb2c7eeba21b75fca9e7879f8b Mon Sep 17 00:00:00 2001 From: John Ottenlips Franke Date: Mon, 18 Sep 2023 10:48:48 -0500 Subject: [PATCH 15/15] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a56298d..b2a10b0 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,5 @@ bun run index.ts ``` You can find more information on Vestaboard subscriptions at https://docs.vestaboard.com. Happy hacking! + +[Issue with delay on GitHub actions during peak traffic times](https://github.com/orgs/community/discussions/52477)