RSSの内容を取得し更新されていたらLINEに通知するサンプルです
これはあくまでサンプルです。リファクタリングや細い認証など行っていないので自己責任でお試しください。
- Node.js
- gcloud command
- GCP Account
- LINE Notifyのaccess_token
- Google App Engine 2nd gen Node.js
- Cloud Tasks
- Cloud Scheduler
- Cloud Datastore
$ npm install
'use strict';
async function saveFeed(url) {
const Datastore = require('@google-cloud/datastore');
const datastore = new Datastore({
projectId: '',
});
const feed = {
key: datastore.key(['Feed']),
data: {
url: url,
date: new Date() //この日時が最終更新日時となる
},
};
return await datastore.save(feed)
}
//GKEのリリースノート
saveFeed("https://cloud.google.com/feeds/kubernetes-engine-release-notes.xml").catch((err) => console.error(err));
LINE_AUTHORIZATION: 'LINE Notifyのaccess_tokenを入れる'
// Cloud Tasksの登録
$ gcloud app deploy queue.yaml
// GAEのデプロイ
$ gcloud app deploy app.yaml --version v1
// Schedulerのセット
$ gcloud beta scheduler jobs create app-engine RSS-Notifier --schedule "0 */3 * * *" --time-zone Asia/Tokyo --description "Notify" --service release-note-notifier --relative-url /v1/tasks/make