Skip to content

Commit

Permalink
Merge pull request #1216 from utelecon/202410-rss-to-twitter
Browse files Browse the repository at this point in the history
implement rss-to-twitter workflow
  • Loading branch information
jtamatsukuri authored Nov 2, 2024
2 parents 795a465 + 8842a4e commit 959ae75
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/rss-to-twitter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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 }}
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 }}
9 changes: 4 additions & 5 deletions src/components/pages/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +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,
pubDate: new Date(notice.date),
});
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({
Expand Down

0 comments on commit 959ae75

Please sign in to comment.