From add56daa25ccf0b2b6816e60c79227867832fda1 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Fri, 7 Nov 2025 15:23:00 +0000 Subject: [PATCH 1/4] chore: update README.md --- README.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bd1543a..dc33591 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,87 @@ This GitHub action starts a [Coder Task](https://coder.com/docs/ai-coder/tasks) and optionally posts a comment on a GitHub issue. It's designed to be used as part of a wider workflow. -## Features +## Overview -- Starts a Coder Task using your specified template and preset -- Posts a single status comment on a GitHub issue -- Maps GitHub users to Coder users +- When creating a Coder task, you must specify the Github user ID as an input. +- The action then queries the Coder deployment to find the Coder user associated with the given Github user ID. + - Note that this requires the Coder deployment to be configured with [GitHub OAuth](https://coder.com/docs/admin/external-auth#configure-a-github-oauth-app) and for the Coder user to have linked their GitHub account. + - If no corresponding Coder user is found, the action will fail. +- The action will then create a [Coder Task](https://coder.com/docs/ai-coder/tasks) for the user with the given template and prompt. +- Once the task has been created successfully, the action will post a comment on the GitHub issue with the task URL. + +## Requirements + +- A running Coder deployment (v2.28 or higher) accessible to the GitHub Actions runner. +- A [Tasks-capable](https://coder.com/docs/ai-coder/tasks#getting-started-with-tasks) Coder template +- A Coder session token with the required permissions to: + - Read all users in the given organization + - Create tasks for any user in the given organization ## Example Usage -TODO +The below example will start a Coder task when the `coder` label is applied to an issue. + +```yaml +name: Start Coder Task + +on: + issues: + types: + - labeled + +permissions: + issues: write + +jobs: + start-coder-task: + runs-on: ubuntu-latest + if: github.event.label.name == 'coder' + steps: + - name: Start Coder Task + uses: coder/start-coder-task@v0.0.2 + with: + coder-url: ${{ secrets.CODER_URL }} + coder-token: ${{ secrets.CODER_TOKEN }} + coder-organization: "default" + coder-template-name: "my-template" + coder-task-name-prefix: "gh-task" + coder-task-prompt: "Use the gh CLI to read ${{ github.event.issue.html_url }}, write an appropriate plan for solving the issue to PLAN.md, and then wait for feedback." + github-user-id: ${{ github.event.sender.id }} + github-issue-url: ${{ github.event.issue.html_url }} + github-token: ${{ github.token }} + comment-on-issue: true +``` + +## Inputs + + + +| Name | Description | Required | Default | +| ---------------------- | --------------------------------------- | -------- | ------- | +| coder-task-prompt | Prompt/instructions to send to the task | true | - | +| coder-token | Coder session token for authentication | true | - | +| coder-url | Coder deployment URL | true | - | +| coder-organization | Coder organization name | true | - | +| coder-task-name-prefix | Prefix for task name | true | - | +| coder-template-name | Coder template to use for workspace | true | - | +| github-issue-url | GitHub issue URL to link this task to | true | - | +| github-token | GitHub token for API operations | true | - | +| github-user-id | GitHub user ID to create task for | true | - | +| coder-template-preset | Template preset to use (optional) | false | - | +| comment-on-issue | Whether to comment on the GitHub issue | false | true | + +## Outputs + + + +| Name | Description | +| -------------- | -------------------------------------------------------------------- | +| coder-username | The Coder username resolved from GitHub user | +| task-name | The task name | +| task-url | The URL to view the task in Coder | +| task-created | Whether the task was newly created (true) or already existed (false) | From 234167d94cde1708d2ca454296b5f91bd952e5d8 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 10 Nov 2025 09:33:05 +0000 Subject: [PATCH 2/4] make org optional with default default --- README.md | 26 +++++++++++++------------- action.yaml | 9 +++++---- src/action.ts | 1 + src/schemas.ts | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index dc33591..89d6d14 100644 --- a/README.md +++ b/README.md @@ -60,19 +60,19 @@ jobs: yq -r '.inputs | to_entries[] | "| \(.key) | \(.value.description) | \(.value.required // false ) | \(.value.default // \"-\") |"' action.yaml --> -| Name | Description | Required | Default | -| ---------------------- | --------------------------------------- | -------- | ------- | -| coder-task-prompt | Prompt/instructions to send to the task | true | - | -| coder-token | Coder session token for authentication | true | - | -| coder-url | Coder deployment URL | true | - | -| coder-organization | Coder organization name | true | - | -| coder-task-name-prefix | Prefix for task name | true | - | -| coder-template-name | Coder template to use for workspace | true | - | -| github-issue-url | GitHub issue URL to link this task to | true | - | -| github-token | GitHub token for API operations | true | - | -| github-user-id | GitHub user ID to create task for | true | - | -| coder-template-preset | Template preset to use (optional) | false | - | -| comment-on-issue | Whether to comment on the GitHub issue | false | true | +| Name | Description | Required | Default | +| ---------------------- | --------------------------------------- | -------- | --------- | +| coder-task-prompt | Prompt/instructions to send to the task | true | - | +| coder-token | Coder session token for authentication | true | - | +| coder-url | Coder deployment URL | true | - | +| coder-task-name-prefix | Prefix for task name | true | - | +| coder-template-name | Coder template to use for workspace | true | - | +| github-issue-url | GitHub issue URL to link this task to | true | - | +| github-token | GitHub token for API operations | true | - | +| github-user-id | GitHub user ID to create task for | true | - | +| coder-organization | Coder organization name | false | "default" | +| coder-template-preset | Template preset to use (optional) | false | - | +| comment-on-issue | Whether to comment on the GitHub issue | false | true | ## Outputs diff --git a/action.yaml b/action.yaml index bce6af2..5ab1acb 100644 --- a/action.yaml +++ b/action.yaml @@ -15,10 +15,6 @@ inputs: description: "Coder deployment URL" required: true - coder-organization: - description: "Coder organization name" - required: true - coder-task-name-prefix: description: "Prefix for task name" required: true @@ -40,6 +36,11 @@ inputs: required: true # Optional inputs + coder-organization: + description: "Coder organization name" + required: false + default: "default" + coder-template-preset: description: "Template preset to use (optional)" required: false diff --git a/src/action.ts b/src/action.ts index 1eaf505..2eb0bfe 100644 --- a/src/action.ts +++ b/src/action.ts @@ -119,6 +119,7 @@ export class CoderTaskAction { "either taskName or both taskNamePrefix and issueURL must be provided", ); } + core.info(`Coder organization: ${this.inputs.coderOrganization}`); const taskNameString = `${this.inputs.coderTaskNamePrefix}-${githubIssueNumber}`; const taskName = TaskNameSchema.parse(taskNameString); core.info(`Coder Task name: ${taskName}`); diff --git a/src/schemas.ts b/src/schemas.ts index 6449a31..7833f02 100644 --- a/src/schemas.ts +++ b/src/schemas.ts @@ -7,13 +7,13 @@ export const ActionInputsSchema = z.object({ coderTaskPrompt: z.string().min(1), coderToken: z.string().min(1), coderURL: z.string().url(), - coderOrganization: z.string().min(1), coderTaskNamePrefix: z.string().min(1), coderTemplateName: z.string().min(1), githubIssueURL: z.string().url(), githubToken: z.string(), githubUserID: z.number().min(1), // Optional + coderOrganization: z.string().min(1).optional().default("default"), coderTemplatePreset: z.string().optional(), commentOnIssue: z.boolean().default(true), }); From 3426160fdec4119a3abc1fc5aa61f4ee30c28594 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 10 Nov 2025 09:56:20 +0000 Subject: [PATCH 3/4] make task name prefix optional with default --- README.md | 2 +- action.yaml | 9 +++++---- dist/index.js | 5 +++-- src/schemas.ts | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 89d6d14..dc1561e 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,12 @@ yq -r '.inputs | to_entries[] | "| \(.key) | \(.value.description) | \(.value.re | coder-task-prompt | Prompt/instructions to send to the task | true | - | | coder-token | Coder session token for authentication | true | - | | coder-url | Coder deployment URL | true | - | -| coder-task-name-prefix | Prefix for task name | true | - | | coder-template-name | Coder template to use for workspace | true | - | | github-issue-url | GitHub issue URL to link this task to | true | - | | github-token | GitHub token for API operations | true | - | | github-user-id | GitHub user ID to create task for | true | - | | coder-organization | Coder organization name | false | "default" | +| coder-task-name-prefix | Prefix for task name | false | "gh" | | coder-template-preset | Template preset to use (optional) | false | - | | comment-on-issue | Whether to comment on the GitHub issue | false | true | diff --git a/action.yaml b/action.yaml index 5ab1acb..6d3c640 100644 --- a/action.yaml +++ b/action.yaml @@ -15,10 +15,6 @@ inputs: description: "Coder deployment URL" required: true - coder-task-name-prefix: - description: "Prefix for task name" - required: true - coder-template-name: description: "Coder template to use for workspace" required: true @@ -41,6 +37,11 @@ inputs: required: false default: "default" + coder-task-name-prefix: + description: "Prefix for task name" + required: false + default: "gh" + coder-template-preset: description: "Template preset to use (optional)" required: false diff --git a/dist/index.js b/dist/index.js index 944e1e4..1ec215a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -26928,6 +26928,7 @@ class CoderTaskAction { if (!this.inputs.coderTaskNamePrefix || !this.inputs.githubIssueURL) { throw new Error("either taskName or both taskNamePrefix and issueURL must be provided"); } + core.info(`Coder organization: ${this.inputs.coderOrganization}`); const taskNameString = `${this.inputs.coderTaskNamePrefix}-${githubIssueNumber}`; const taskName = TaskNameSchema.parse(taskNameString); core.info(`Coder Task name: ${taskName}`); @@ -27004,12 +27005,12 @@ var ActionInputsSchema = exports_external.object({ coderTaskPrompt: exports_external.string().min(1), coderToken: exports_external.string().min(1), coderURL: exports_external.string().url(), - coderOrganization: exports_external.string().min(1), - coderTaskNamePrefix: exports_external.string().min(1), coderTemplateName: exports_external.string().min(1), githubIssueURL: exports_external.string().url(), githubToken: exports_external.string(), githubUserID: exports_external.number().min(1), + coderOrganization: exports_external.string().min(1).optional().default("default"), + coderTaskNamePrefix: exports_external.string().min(1).optional().default("gh"), coderTemplatePreset: exports_external.string().optional(), commentOnIssue: exports_external.boolean().default(true) }); diff --git a/src/schemas.ts b/src/schemas.ts index 7833f02..295f854 100644 --- a/src/schemas.ts +++ b/src/schemas.ts @@ -7,13 +7,13 @@ export const ActionInputsSchema = z.object({ coderTaskPrompt: z.string().min(1), coderToken: z.string().min(1), coderURL: z.string().url(), - coderTaskNamePrefix: z.string().min(1), coderTemplateName: z.string().min(1), githubIssueURL: z.string().url(), githubToken: z.string(), githubUserID: z.number().min(1), // Optional coderOrganization: z.string().min(1).optional().default("default"), + coderTaskNamePrefix: z.string().min(1).optional().default("gh"), coderTemplatePreset: z.string().optional(), commentOnIssue: z.boolean().default(true), }); From 891408fd13aaf58cd0325b02083c79ec19086047 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 10 Nov 2025 09:58:10 +0000 Subject: [PATCH 4/4] bun --- bun.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/bun.lock b/bun.lock index d8d8535..7488649 100644 --- a/bun.lock +++ b/bun.lock @@ -1,5 +1,6 @@ { "lockfileVersion": 1, + "configVersion": 0, "workspaces": { "": { "name": "coder-task-action",