はじめに
おそらくいろんなやり方が考えられるが、簡単かつ無料で行える方法としてGithub Actionsを使った方法を紹介する
手順
以下のようなワークフローをgithub actionsで作成する
.github/workflows/trigger-dify-workflow.yml
name: Trigger Dify Workflow
on:
schedule:
- cron: "0 0 * * *" # 毎日9時(日本時間)に実行
workflow_dispatch: # 手動実行も可能にしている
jobs:
call-dify:
runs-on: ubuntu-latest
steps:
- name: Call Dify API
run: |
curl -X POST "https://api.dify.ai/v1/workflows/run" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ secrets.DIFY_API_SECRET_KEY }}" \
-d '{
"user": "github-actions",
"response_mode": "blocking",
"inputs": {}
}'
以上。
実行頻度を変えたい場合
-
cron: "0 0 * * *"
を変更する - 詳細: https://docs.github.com/ja/actions/reference/workflows-and-actions/events-that-trigger-workflows#schedule
参考