Skip to content

This is script Habitica's completed tasks sync with Google Calendar.

Notifications You must be signed in to change notification settings

gyvm/habitica-sync-with-gcal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

habitica-sync-with-gcal

habitica-task-sync-with-gcalはhabiticaでタスク(習慣、日課、To Do)を完了した際に、Googleカレンダーにイベントを登録するためのスクリプトです。
Google Cloud Runで動作します。起動方法は以下をご確認ください。 

スクリーンショット 2021-08-30 5 46 00

起動方法

手順

  1. Google Calendar APIを有効化
  2. GCPのサービスアカウントを作成
  3. Googleカレンダーへサービスアカウントを登録
  4. main.pyの編集
  5. デプロイ

必要な情報

1. Google Calendar APIを有効化する

  1. https://console.cloud.google.com/apis/library からGoogle Calendar APIを検索し有効化する

スクリーンショット 2021-08-30 4 25 09

2. GCPのサービスアカウントを作成する

  1. GCPコンソール「IAMと管理」の「サービスアカウント」ページにて「サービスアカウントを作成」を行う

スクリーンショット 2021-08-30 5 30 10

  1. サービスアカウントの鍵を作成する
    • 作成された対象の縦三点リーダー(メニュー)より「鍵を管理」を選択する
    • 「新しい鍵を作成」にてJSON型の秘密鍵を生成、ダウンロードする

スクリーンショット 2021-08-30 5 38 42

  1. habitica-task-sync-with-gcal/配下(main.pyの存在するディレクトリ)にダウンロードした秘密鍵のファイルをcredentials.jsonとしてコピーする

3. Googleカレンダーへサービスアカウントを登録する

  1. 利用するGoogleカレンダーの設定にて、「特定のユーザーとの共有」へ作成したサービスアカウントを追加する
  • サービスアカウントのメールの値を追加する

スクリーンショット 2021-08-30 5 31 04

4. main.pyの編集

  1. 下記項目を入力する

    • CALENDAER_IDは利用するGoogleカレンダーIDを設定
    • HABITICA_USER_IDHABITICA_API_TOKENはHabiticaの設定、APIページで確認可能
    # 入力する
    CALENDAER_ID = ''
    HABITICA_USER_ID = ''
    HABITICA_API_TOKEN = ''
    

スクリーンショット 2021-08-30 4 10 11

5. デプロイ

  1. gcloud builds submitコマンドでDockerコンテナをビルドする

    gcloud builds submit --tag=gcr.io/my-project/image
    
  2. Google Cloud Runへデプロイ

    • 下記コマンドでビルドしたDockerコンテナをCloud Runへデプロイする
      • コマンド実行中、Cloud Runでのサービス名、リージョンを設定する
    gcloud run deploy --image gcr.io/my-project/image
    
  3. HabiticaへWebhook URLを登録する

    • Habiticaの設定、APIページのWebhook URLへ対象Cloud RunのURLを登録する

About

This is script Habitica's completed tasks sync with Google Calendar.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published