From 028713fa7cd4cf85e989d27c2bef6c3cf816ce1a Mon Sep 17 00:00:00 2001 From: Futa IWATA Date: Sun, 6 Oct 2024 15:21:48 +0900 Subject: [PATCH 1/5] implement rss-to-twitter workflow --- .github/workflows/rss-to-twitter.yml | 21 +++++++++++++++++++++ src/pages/notice/rss.xml.ts | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/rss-to-twitter.yml diff --git a/.github/workflows/rss-to-twitter.yml b/.github/workflows/rss-to-twitter.yml new file mode 100644 index 0000000000..294be5150c --- /dev/null +++ b/.github/workflows/rss-to-twitter.yml @@ -0,0 +1,21 @@ +name: rss-to-twitter + +on: + schedule: + # everyday at 01:00 UTC (10:00 JST) + - cron: '0 1 * * *' + +jobs: + twitter: + runs-on: ubuntu-latest + steps: + - uses: azu/rss-to-twitter@v2 + with: + # RSS feed URL + RSS_URL: "https://utelecon.adm.u-tokyo.ac.jp/notice/rss.xml" + # UPDATE_WITHIN_MINUTES is calculated from cron schedule to be 1 day + TWEET_TEMPLATE: '%title% %url%' + TWITTER_APIKEY: ${{ secrets.TWITTER_APIKEY }} + TWITTER_APIKEY_SECRET: ${{ secrets.TWITTER_APIKEY_SECRET }} + TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} + TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} diff --git a/src/pages/notice/rss.xml.ts b/src/pages/notice/rss.xml.ts index a8910b4ef3..d8ffab1c74 100644 --- a/src/pages/notice/rss.xml.ts +++ b/src/pages/notice/rss.xml.ts @@ -29,7 +29,8 @@ export async function GET(context: APIContext) { itemsMap.set(link, { title, link, - pubDate: new Date(notice.date), + // 00:00 on next day in order for rss-to-twitter to work correctly + pubDate: new Date(notice.date.getTime() + 24 * 60 * 60 * 1000), }); } From 153b76df99915a5f2a4559f49414971d23719910 Mon Sep 17 00:00:00 2001 From: Futa IWATA Date: Mon, 21 Oct 2024 07:46:30 +0900 Subject: [PATCH 2/5] add en --- .github/workflows/rss-to-twitter.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/rss-to-twitter.yml b/.github/workflows/rss-to-twitter.yml index 294be5150c..317f8cc8af 100644 --- a/.github/workflows/rss-to-twitter.yml +++ b/.github/workflows/rss-to-twitter.yml @@ -19,3 +19,16 @@ jobs: TWITTER_APIKEY_SECRET: ${{ secrets.TWITTER_APIKEY_SECRET }} TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} + twitter-en: + runs-on: ubuntu-latest + steps: + - uses: azu/rss-to-twitter@v2 + with: + # RSS feed URL + RSS_URL: "https://utelecon.adm.u-tokyo.ac.jp/en/notice/rss.xml" + # UPDATE_WITHIN_MINUTES is calculated from cron schedule to be 1 day + TWEET_TEMPLATE: '%title% %url%' + TWITTER_APIKEY: ${{ secrets.TWITTER_EN_APIKEY }} + TWITTER_APIKEY_SECRET: ${{ secrets.TWITTER_EN_APIKEY_SECRET }} + TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_EN_ACCESS_TOKEN }} + TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_EN_ACCESS_TOKEN_SECRET }} From ca8468d9eaf46ef543fd611e480cc616e62ab277 Mon Sep 17 00:00:00 2001 From: Futa IWATA Date: Fri, 1 Nov 2024 15:55:49 +0900 Subject: [PATCH 3/5] reflect diff from conflict --- src/components/pages/rss.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/pages/rss.ts b/src/components/pages/rss.ts index f862629925..ddc43a9cb7 100644 --- a/src/components/pages/rss.ts +++ b/src/components/pages/rss.ts @@ -36,7 +36,8 @@ export async function rss({ title, description, url, lang }: RssParams) { itemsMap.set(link, { title, link, - pubDate: new Date(notice.date), + // 00:00 on next day in order for rss-to-twitter to work correctly + pubDate: new Date(notice.date.getTime() + 24 * 60 * 60 * 1000), }); } From e3bd82200f142909e7002d8f943a738f7d64a91a Mon Sep 17 00:00:00 2001 From: Futa IWATA Date: Sat, 2 Nov 2024 08:21:35 +0900 Subject: [PATCH 4/5] change pubDate time --- src/components/pages/rss.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/pages/rss.ts b/src/components/pages/rss.ts index ddc43a9cb7..a53b4f7660 100644 --- a/src/components/pages/rss.ts +++ b/src/components/pages/rss.ts @@ -36,8 +36,8 @@ export async function rss({ title, description, url, lang }: RssParams) { itemsMap.set(link, { title, link, - // 00:00 on next day in order for rss-to-twitter to work correctly - pubDate: new Date(notice.date.getTime() + 24 * 60 * 60 * 1000), + // 12:00 of the day in order for rss-to-twitter to work correctly + pubDate: new Date(notice.date.getTime() + 12 * 60 * 60 * 1000), }); } From 8842a4ed513e496f40f4195e315fd06bdc270e48 Mon Sep 17 00:00:00 2001 From: Futa IWATA Date: Sat, 2 Nov 2024 08:48:10 +0900 Subject: [PATCH 5/5] use utc time --- src/components/pages/rss.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/pages/rss.ts b/src/components/pages/rss.ts index a53b4f7660..b3b752f411 100644 --- a/src/components/pages/rss.ts +++ b/src/components/pages/rss.ts @@ -33,12 +33,10 @@ export async function rss({ title, description, url, lang }: RssParams) { a && toText(a) === title ? (a.properties.href as string) : `/notice/#${notice.id}`; - itemsMap.set(link, { - title, - link, - // 12:00 of the day in order for rss-to-twitter to work correctly - pubDate: new Date(notice.date.getTime() + 12 * 60 * 60 * 1000), - }); + const pubDate = new Date(notice.date); + // 03:00 UTC (12:00 JST) of the day in order for rss-to-twitter.yml to work correctly + pubDate.setUTCHours(3); + itemsMap.set(link, { title, link, pubDate }); } return getRssResponse({