8000 more defaults for inputs · coder/start-workspace-action@a09e31d · GitHub
[go: up one dir, main page]

Skip to content

Commit a09e31d

Browse files
committed
more defaults for inputs
1 parent 1330420 commit a09e31d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

action.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ inputs:
66
required: false
77
default: ${{ github.token }}
88
github-issue-number:
9-
description: 'GitHub issue number where the status comment will be posted'
10-
required: true
9+
description: 'GitHub issue number where the status comment will be posted (defaults to current issue context)'
10+
required: false
1111
github-username:
1212
description: 'GitHub username of the user for whom the workspace is being started'
1313
required: false
@@ -24,8 +24,8 @@ inputs:
2424
description: 'Name of the Coder template to use'
2525
required: true
2626
workspace-name:
27-
description: 'Name for the new workspace'
28-
required: true
27+
description: 'Name for the new workspace (defaults to issue-{issue_number})'
28+
required: false
2929
parameters:
3030
description: 'YAML-formatted parameters for the Coder workspace'
3131
required: true
@@ -39,7 +39,11 @@ runs:
3939
with:
4040
github-token: ${{ inputs.github-token }}
4141
script: |
42-
const issueNumber = Number('${{ inputs.github-issue-number }}');
42+
const issueNumber = '${{ inputs.github-issue-number }}' ? Number('${{ inputs.github-issue-number }}') : github.context.issue.number;
43+
if (!issueNumber) {
44+
core.setFailed('No issue number provided and no issue context available');
45+
return;
46+
}
4347
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
4448
const comment = await github.rest.issues.createComment({
4549
owner: context.repo.owner,
@@ -51,6 +55,7 @@ runs:
5155
core.setOutput('run_url', runUrl);
5256
core.setOutput('repo_owner', context.repo.owner);
5357
core.setOutput('repo_name', context.repo.repo);
58+
core.setOutput('issue_number', issueNumber);
5459
5560
- name: Start workspace
5661
shell: bash
@@ -59,7 +64,8 @@ runs:
5964
CODER_USERNAME: ${{ inputs.coder-username }}
6065
CODER_URL: ${{ inputs.coder-url }}
6166
CODER_TOKEN: ${{ inputs.coder-token }}
62-
WORKSPACE_NAME: ${{ inputs.workspace-name }}
67+
WORKSPACE_NAME: ${{ inputs.workspace-name || format('issue-{0}', steps.initial-comment.outputs.issue_number) }}
68+
GITHUB_ISSUE_NUMBER: ${{ steps.initial-comment.outputs.issue_number }}
6369
GITHUB_STATUS_COMMENT_ID: ${{ steps.initial-comment.outputs.comment_id }}
6470
GITHUB_REPO_OWNER: ${{ steps.initial-comment.outputs.repo_owner }}
6571
GITHUB_REPO_NAME: ${{ steps.initial-comment.outputs.repo_name }}
@@ -76,6 +82,10 @@ runs:
7682
with:
7783
github-token: ${{ inputs.github-token }}
7884
script: |
85+
if (!steps.initial-comment.outputs.comment_id) {
86+
core.warning('No comment ID found, skipping status update');
87+
return;
88+
}
7989
const commentId = Number('${{ steps.initial-comment.outputs.comment_id }}');
8090
const runUrl = '${{ steps.initial-comment.outputs.run_url }}';
8191
const errorMsg = process.env["ERROR_MSG"];

0 commit comments

Comments
 (0)
0