6
6
required : false
7
7
default : ${{ github.token }}
8
8
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
11
11
github-username :
12
12
description : ' GitHub username of the user for whom the workspace is being started'
13
13
required : false
@@ -24,8 +24,8 @@ inputs:
24
24
description : ' Name of the Coder template to use'
25
25
required : true
26
26
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
29
29
parameters :
30
30
description : ' YAML-formatted parameters for the Coder workspace'
31
31
required : true
39
39
with :
40
40
github-token : ${{ inputs.github-token }}
41
41
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
+ }
43
47
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
44
48
const comment = await github.rest.issues.createComment({
45
49
owner: context.repo.owner,
51
55
core.setOutput('run_url', runUrl);
52
56
core.setOutput('repo_owner', context.repo.owner);
53
57
core.setOutput('repo_name', context.repo.repo);
58
+ core.setOutput('issue_number', issueNumber);
54
59
55
60
- name : Start workspace
56
61
shell : bash
59
64
CODER_USERNAME : ${{ inputs.coder-username }}
60
65
CODER_URL : ${{ inputs.coder-url }}
61
66
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 }}
63
69
GITHUB_STATUS_COMMENT_ID : ${{ steps.initial-comment.outputs.comment_id }}
64
70
GITHUB_REPO_OWNER : ${{ steps.initial-comment.outputs.repo_owner }}
65
71
GITHUB_REPO_NAME : ${{ steps.initial-comment.outputs.repo_name }}
76
82
with :
77
83
github-token : ${{ inputs.github-token }}
78
84
script : |
85
+ if (!steps.initial-comment.outputs.comment_id) {
86
+ core.warning('No comment ID found, skipping status update');
87
+ return;
88
+ }
79
89
const commentId = Number('${{ steps.initial-comment.outputs.comment_id }}');
80
90
const runUrl = '${{ steps.initial-comment.outputs.run_url }}';
81
91
const errorMsg = process.env["ERROR_MSG"];
0 commit comments