|
| 1 | +name: "Cortex Code Action" |
| 2 | +description: "GitHub Action that integrates Snowflake Cortex Code as an AI assistant for PRs and issues. Triggered by @cortex-code mentions." |
| 3 | +author: "Snowflake Cortex Code" |
| 4 | + |
| 5 | +branding: |
| 6 | + icon: "code" |
| 7 | + color: "blue" |
| 8 | + |
| 9 | +inputs: |
| 10 | + trigger_phrase: |
| 11 | + description: "Phrase that triggers the action in comments" |
| 12 | + required: false |
| 13 | + default: "@cortex-code" |
| 14 | + snowflake_account: |
| 15 | + description: "Snowflake account identifier (e.g., myorg-myaccount)" |
| 16 | + required: true |
| 17 | + snowflake_user: |
| 18 | + description: "Snowflake username for authentication" |
| 19 | + required: true |
| 20 | + snowflake_private_key: |
| 21 | + description: "Snowflake key-pair private key (PEM format). Mutually exclusive with snowflake_api_key." |
| 22 | + required: false |
| 23 | + snowflake_api_key: |
| 24 | + description: "Snowflake API key or PAT. Mutually exclusive with snowflake_private_key." |
| 25 | + required: false |
| 26 | + github_token: |
| 27 | + description: "GitHub token for API operations (PR comments, status checks)" |
| 28 | + required: false |
| 29 | + default: ${{ github.token }} |
| 30 | + model: |
| 31 | + description: "Model identifier for Cortex Code (e.g., auto, claude-sonnet-4-6, openai-gpt-5.2)" |
| 32 | + required: false |
| 33 | + default: "auto" |
| 34 | + allowed_tools: |
| 35 | + description: "Comma-separated additional tools to allow (e.g., SQL,WebSearch)" |
| 36 | + required: false |
| 37 | + default: "" |
| 38 | + disallowed_tools: |
| 39 | + description: "Comma-separated tools to deny" |
| 40 | + required: false |
| 41 | + default: "" |
| 42 | + system_prompt: |
| 43 | + description: "Additional system prompt text to append to the default" |
| 44 | + required: false |
| 45 | + default: "" |
| 46 | + branch_prefix: |
| 47 | + description: "Prefix for branches created by Cortex Code" |
| 48 | + required: false |
| 49 | + default: "cortex-code/" |
| 50 | + bot_name: |
| 51 | + description: "Display name for the bot in git operations" |
| 52 | + required: false |
| 53 | + default: "cortex-code[bot]" |
| 54 | + bot_id: |
| 55 | + description: "GitHub user ID for git operations" |
| 56 | + required: false |
| 57 | + default: "41898282" |
| 58 | + max_turns: |
| 59 | + description: "Maximum number of agentic turns before stopping" |
| 60 | + required: false |
| 61 | + default: "25" |
| 62 | + timeout_minutes: |
| 63 | + description: "Maximum execution time in minutes before the action is terminated" |
| 64 | + required: false |
| 65 | + default: "10" |
| 66 | + base_branch: |
| 67 | + description: "Base branch for new branches (defaults to repo default branch)" |
| 68 | + required: false |
| 69 | + default: "" |
| 70 | + prompt: |
| 71 | + description: "Direct prompt for agent mode. When provided, skips trigger detection and uses this as the instruction (e.g., for automated PR reviews)." |
| 72 | + required: false |
| 73 | + default: "" |
| 74 | + review_mode: |
| 75 | + description: "When true, restricts tools to read-only (no Bash, Write, Edit). Ideal for automated PR reviews." |
| 76 | + required: false |
| 77 | + default: "" |
| 78 | + |
| 79 | +outputs: |
| 80 | + branch_name: |
| 81 | + description: "The branch created or used by Cortex Code" |
| 82 | + value: ${{ steps.run.outputs.branch_name }} |
| 83 | + session_id: |
| 84 | + description: "Cortex Code session ID for resuming" |
| 85 | + value: ${{ steps.run.outputs.session_id }} |
| 86 | + conclusion: |
| 87 | + description: "Result status: success or failure" |
| 88 | + value: ${{ steps.run.outputs.conclusion }} |
| 89 | + |
| 90 | +runs: |
| 91 | + using: "composite" |
| 92 | + steps: |
| 93 | + - name: Install Bun |
| 94 | + uses: oven-sh/setup-bun@v2 |
| 95 | + with: |
| 96 | + bun-version: "1.3.6" |
| 97 | + |
| 98 | + - name: Install dependencies |
| 99 | + shell: bash |
| 100 | + working-directory: ${{ github.action_path }} |
| 101 | + run: bun install --production --frozen-lockfile || bun install --production |
| 102 | + |
| 103 | + - name: Install Cortex Code CLI |
| 104 | + shell: bash |
| 105 | + run: | |
| 106 | + curl -LsS https://ai.snowflake.com/static/cc-scripts/install.sh | sh |
| 107 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 108 | +
|
| 109 | + - name: Run Cortex Code Action |
| 110 | + id: run |
| 111 | + shell: bash |
| 112 | + working-directory: ${{ github.action_path }} |
| 113 | + env: |
| 114 | + GITHUB_TOKEN: ${{ inputs.github_token }} |
| 115 | + SNOWFLAKE_ACCOUNT: ${{ inputs.snowflake_account }} |
| 116 | + SNOWFLAKE_USER: ${{ inputs.snowflake_user }} |
| 117 | + SNOWFLAKE_PRIVATE_KEY: ${{ inputs.snowflake_private_key }} |
| 118 | + SNOWFLAKE_API_KEY: ${{ inputs.snowflake_api_key }} |
| 119 | + INPUT_TRIGGER_PHRASE: ${{ inputs.trigger_phrase }} |
| 120 | + INPUT_MODEL: ${{ inputs.model }} |
| 121 | + INPUT_ALLOWED_TOOLS: ${{ inputs.allowed_tools }} |
| 122 | + INPUT_DISALLOWED_TOOLS: ${{ inputs.disallowed_tools }} |
| 123 | + INPUT_SYSTEM_PROMPT: ${{ inputs.system_prompt }} |
| 124 | + INPUT_BRANCH_PREFIX: ${{ inputs.branch_prefix }} |
| 125 | + INPUT_BOT_NAME: ${{ inputs.bot_name }} |
| 126 | + INPUT_BOT_ID: ${{ inputs.bot_id }} |
| 127 | + INPUT_MAX_TURNS: ${{ inputs.max_turns }} |
| 128 | + INPUT_TIMEOUT_MINUTES: ${{ inputs.timeout_minutes }} |
| 129 | + INPUT_BASE_BRANCH: ${{ inputs.base_branch }} |
| 130 | + INPUT_PROMPT: ${{ inputs.prompt }} |
| 131 | + INPUT_REVIEW_MODE: ${{ inputs.review_mode }} |
| 132 | + run: bun run src/entrypoints/run.ts |
0 commit comments