|
| 1 | +# Template for generated scheduled agent-action workflows. |
| 2 | +# Copy this file to .github/workflows/agent-action-<short-slug>.yml and |
| 3 | +# replace the placeholder name, cron, expiration, lane, request text, and |
| 4 | +# optional issue-report target. |
| 5 | + |
| 6 | +name: Agent Action / Example |
| 7 | + |
| 8 | +on: |
| 9 | + schedule: |
| 10 | + - cron: "17 * * * *" |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +permissions: |
| 14 | + actions: read |
| 15 | + contents: read |
| 16 | + # If enabling REPORT_ISSUE_NUMBER below, add issue write permission. |
| 17 | + id-token: write |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: agent-action-example-${{ github.repository }} |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +env: |
| 24 | + ACTION_EXPIRES_AT: "YYYY-MM-DD" |
| 25 | + REPORT_ISSUE_NUMBER: "" |
| 26 | + |
| 27 | +jobs: |
| 28 | + run: |
| 29 | + if: vars.AGENT_ENABLED != 'false' |
| 30 | + runs-on: ${{ fromJson(vars.AGENT_RUNS_ON || '["ubuntu-latest"]') }} |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + fetch-depth: 1 |
| 35 | + token: ${{ github.token }} |
| 36 | + |
| 37 | + - name: Check expiration |
| 38 | + id: expiration |
| 39 | + uses: ./.github/actions/check-agent-action-expiration |
| 40 | + with: |
| 41 | + expires_at: ${{ env.ACTION_EXPIRES_AT }} |
| 42 | + |
| 43 | + - name: Resolve GitHub auth |
| 44 | + if: steps.expiration.outputs.expired != 'true' |
| 45 | + id: auth |
| 46 | + uses: ./.github/actions/resolve-github-auth |
| 47 | + with: |
| 48 | + app_id: ${{ secrets.AGENT_APP_ID }} |
| 49 | + app_private_key: ${{ secrets.AGENT_APP_PRIVATE_KEY }} |
| 50 | + pat: ${{ secrets.AGENT_PAT }} |
| 51 | + fallback_token: ${{ github.token }} |
| 52 | + |
| 53 | + - name: Resolve provider |
| 54 | + if: steps.expiration.outputs.expired != 'true' |
| 55 | + id: provider |
| 56 | + uses: ./.github/actions/resolve-agent-provider |
| 57 | + with: |
| 58 | + route: answer |
| 59 | + default_provider: ${{ vars.AGENT_DEFAULT_PROVIDER || 'auto' }} |
| 60 | + openai_api_key: ${{ secrets.OPENAI_API_KEY }} |
| 61 | + claude_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 62 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 63 | + model_policy: ${{ vars.AGENT_MODEL_POLICY || '' }} |
| 64 | + |
| 65 | + - name: Setup agent runtime |
| 66 | + if: steps.expiration.outputs.expired != 'true' |
| 67 | + uses: ./.github/actions/setup-agent-runtime |
| 68 | + with: |
| 69 | + install_codex: ${{ steps.provider.outputs.install_codex }} |
| 70 | + install_claude: ${{ steps.provider.outputs.install_claude }} |
| 71 | + |
| 72 | + - name: Resolve task timeout |
| 73 | + if: steps.expiration.outputs.expired != 'true' |
| 74 | + id: task_timeout |
| 75 | + env: |
| 76 | + AGENT_TASK_TIMEOUT_POLICY: ${{ vars.AGENT_TASK_TIMEOUT_POLICY || '' }} |
| 77 | + ROUTE: answer |
| 78 | + run: node .agent/dist/cli/resolve-task-timeout.js |
| 79 | + |
| 80 | + - name: Run scheduled agent task |
| 81 | + if: steps.expiration.outputs.expired != 'true' |
| 82 | + id: agent |
| 83 | + timeout-minutes: ${{ fromJson(steps.task_timeout.outputs.minutes || '30') }} |
| 84 | + uses: ./.github/actions/run-agent-task |
| 85 | + with: |
| 86 | + agent: ${{ steps.provider.outputs.provider }} |
| 87 | + github_token: ${{ steps.auth.outputs.token }} |
| 88 | + secondary_github_token: ${{ secrets.AGENT_SECONDARY_GITHUB_TOKEN }} |
| 89 | + openai_api_key: ${{ secrets.OPENAI_API_KEY }} |
| 90 | + claude_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 91 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 92 | + model: ${{ steps.provider.outputs.model }} |
| 93 | + display_model: ${{ vars.AGENT_DISPLAY_MODEL || '' }} |
| 94 | + reasoning_effort: ${{ steps.provider.outputs.reasoning_effort || 'xhigh' }} |
| 95 | + permission_mode: approve-all |
| 96 | + prompt: answer |
| 97 | + route: answer |
| 98 | + lane: agent-action-example |
| 99 | + memory_mode_override: read-only |
| 100 | + session_policy: track-only |
| 101 | + request_text: | |
| 102 | + Describe the bounded recurring task here. |
| 103 | + requested_by: ${{ github.actor }} |
| 104 | + source_kind: workflow_dispatch |
| 105 | + target_kind: repository |
| 106 | + target_number: "0" |
| 107 | + target_url: ${{ github.server_url }}/${{ github.repository }} |
| 108 | + workflow: agent-action-example.yml |
| 109 | + |
| 110 | + # Optional: set REPORT_ISSUE_NUMBER and add issue write permission only when the workflow should report to an issue. |
| 111 | + - name: Post report to issue |
| 112 | + if: >- |
| 113 | + steps.expiration.outputs.expired != 'true' && |
| 114 | + steps.agent.outcome == 'success' && |
| 115 | + env.REPORT_ISSUE_NUMBER != '' |
| 116 | + env: |
| 117 | + BODY_FILE: ${{ steps.agent.outputs.response_file }} |
| 118 | + MODEL_DISPLAY: ${{ steps.agent.outputs.model_display }} |
| 119 | + GH_TOKEN: ${{ steps.auth.outputs.token }} |
| 120 | + GITHUB_REPOSITORY: ${{ github.repository }} |
| 121 | + RESPONSE_KIND: issue_comment |
| 122 | + TARGET_NUMBER: ${{ env.REPORT_ISSUE_NUMBER }} |
| 123 | + run: node .agent/dist/cli/post-response.js |
0 commit comments