{"id":46231980,"url":"https://github.com/pepabo/dify-cron","last_synced_at":"2026-03-03T18:07:23.065Z","repository":{"id":285700206,"uuid":"958763070","full_name":"pepabo/dify-cron","owner":"pepabo","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-02T07:39:26.000Z","size":119,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-02T08:22:06.573Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pepabo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-01T18:11:08.000Z","updated_at":"2025-04-02T07:39:29.000Z","dependencies_parsed_at":"2025-04-02T08:22:10.191Z","dependency_job_id":"5e24ce3b-0c0f-4907-81bc-2fe98384ad6d","html_url":"https://github.com/pepabo/dify-cron","commit_stats":null,"previous_names":["pepabo/dify-cron"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pepabo/dify-cron","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pepabo%2Fdify-cron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pepabo%2Fdify-cron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pepabo%2Fdify-cron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pepabo%2Fdify-cron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pepabo","download_url":"https://codeload.github.com/pepabo/dify-cron/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pepabo%2Fdify-cron/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30054070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T17:46:22.538Z","status":"ssl_error","status_checked_at":"2026-03-03T17:46:22.036Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-03T18:07:22.552Z","updated_at":"2026-03-03T18:07:23.056Z","avatar_url":"https://github.com/pepabo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dify Cron\n\nDify APIを利用して、Googleスプレッドシートでcron設定を管理し、Difyのワークフローを定期実行するGoogle Apps Scriptプロジェクトです。\n\n## 概要\n\nこのプロジェクトは以下の機能を提供します：\n\n- Dify APIを使ったアプリケーション一覧の取得\n- Googleスプレッドシートを使ったcron設定の管理\n- cron形式でのワークフロー実行スケジュール設定\n- 定期的なDifyアプリ一覧との同期\n\n## インストール\n\n### 前提条件\n\n- Node.js と npm がインストールされていること\n- Google Apps Scriptへのアクセス権があること\n- **Google Apps Script API**が有効になっていること\n  - 有効化するには [https://script.google.com/home/usersettings](https://script.google.com/home/usersettings) にアクセスし、「Google Apps Script API」をONにしてください\n  - API有効化後、反映されるまで数分かかる場合があります\n\n### 手順\n\n1. リポジトリをクローン\n   ```\n   git clone https://github.com/yourorganization/dify-cron.git\n   cd dify-cron\n   ```\n\n2. 依存パッケージのインストール\n   ```\n   npm install\n   ```\n\n3. claspでログイン\n   ```\n   npm run clasp:login\n   ```\n\n4. Google Apps Scriptプロジェクトを作成\n   ```\n   npm run clasp:create\n   ```\n\n5. プロジェクトをデプロイ\n   ```\n   npm run clasp:push\n   ```\n\n6. デプロイバージョンを作成\n   ```\n   npm run clasp:deploy\n   ```\n\n7. GASプロジェクト設定\n   - プロジェクトルートに`appsscript.json`ファイルを作成（テンプレートとしての`appsscript.json.sample`をコピー）\n   - 必要に応じてタイムゾーンなどを調整（日本の場合は`\"timeZone\": \"Asia/Tokyo\"`）\n\n## 設定\n\n1. Google Apps Scriptプロジェクトでスクリプトプロパティを設定\n   - `DIFY_BASE_URL`: DifyのAPIベースURL\n   - `DIFY_USERNAME`: DifyのAPIアクセス用ユーザー名\n   - `DIFY_PASSWORD`: DifyのAPIアクセス用パスワード\n\n2. トリガーの設定\n   - `syncDifyApps`関数のトリガーを設定（1時間ごとなど）\n   - `checkAndRunCronJobs`関数のトリガーを設定（1分ごと）\n\n## 使用方法\n\n### 初期セットアップ\n\n1. Google Apps ScriptエディタでプロジェクトをGoogleスプレッドシートに紐づけます\n2. `syncDifyApps`関数を実行して、Difyのアプリ一覧をスプレッドシートに同期します\n3. スプレッドシート上でcron設定を行います\n   - `Enabled`列のチェックボックスをONにすると、そのアプリがcron実行の対象になります\n   - cron形式（分、時、日、月、曜日）で実行スケジュールを設定します\n\n### APIキーの設定\n\nワークフローを実行するには、各アプリのAPIキーをスプレッドシートに設定する必要があります：\n\n1. Difyの各アプリの「ワークフローアプリAPI」画面でAPIキーを発行します\n2. スプレッドシートのAPI Secret列に発行したAPIキーを入力します\n\n### スプレッドシートの列構成\n\n- `Enabled`: 実行対象にするかどうかのチェックボックス（デフォルトはfalse）\n- `ID`: アプリID（自動設定）\n- `Name`: アプリ名（自動設定）\n- `Description`: 説明（自動設定）\n- `API Secret`: APIシークレットキー（アプリごとに設定）\n- `Cron Minutes`: 分（0-59）\n- `Cron Hours`: 時（0-23）\n- `Cron Day of Month`: 日（1-31）\n- `Cron Month`: 月（1-12）\n- `Cron Day of Week`: 曜日（0-6、0=日曜）\n- `Args`: JSON形式の引数\n- `Last Sync`: 最終同期日時\n- `Last Run`: 最終実行日時\n\n### Cron記法\n\ncron設定は標準的な5つのフィールド（分、時、日、月、曜日）で構成されます。\n\n- `*`: すべての値（毎分、毎時など）\n- `5`: 特定の値（5分、5時など）\n- `1-5`: 範囲（1分から5分、1時から5時など）\n- `*/15`: 間隔（15分ごと、15時間ごとなど）\n- `5,10,15`: リスト（5分、10分、15分など）\n\n例：\n- `30 9 * * 1-5`: 平日（月〜金）の9:30に実行\n- `0 */2 * * *`: 2時間おきに実行（0時、2時、4時...）\n- `0 0 1 * *`: 毎月1日の0:00に実行\n\n## 主要機能\n\n### Difyアプリ同期\n\n`syncDifyApps`関数はDify APIからアプリ一覧を取得し、スプレッドシートと同期します。\n- 新規アプリはスプレッドシートに追加されます（デフォルトでは無効状態）\n- 既存アプリの名前や説明が更新されます（Enabled状態やcron設定は保持）\n- Difyで削除されたアプリはスプレッドシートからも削除されます\n\n### Cronジョブ実行\n\n`checkAndRunCronJobs`関数は1分ごとに実行され、以下の処理を行います：\n- スプレッドシートからEnabled状態のアプリを取得\n- 現在時刻がcron設定に合致するかチェック\n- 合致した場合、Dify APIを使用してワークフローを実行\n- 実行履歴を更新\n\n## 開発\n\n### テスト実行\n\n```\nnpm test\n```\n\n### 継続的テスト実行\n\n```\nnpm run test:watch\n```\n\n### カバレッジレポート生成\n\n```\nnpm run test:coverage\n```\n\n### ビルド\n\n```\nnpm run build\n```\n\n### デプロイ\n\n```\nnpm run deploy\n```\n\nまたは個別のステップで：\n\n```\n# ビルド\nnpm run build\n\n# GASにプッシュ\nnpm run clasp:push\n\n# デプロイバージョン作成\nnpm run clasp:deploy\n```\n\n## ライセンス\n\n[MIT License](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpepabo%2Fdify-cron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpepabo%2Fdify-cron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpepabo%2Fdify-cron/lists"}