Skip to content

Commit b30ab70

Browse files
committed
Fix deployment id
1 parent 68efd59 commit b30ab70

File tree

8 files changed

+93
-35
lines changed

8 files changed

+93
-35
lines changed

dist/api-client.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34670,6 +34670,12 @@ async function sendDeploymentEvent(apiUrl, apiKey, payload, failOnRejection = fa
3467034670
});
3467134671
core.info(`✅ Deployment event created successfully`);
3467234672
core.debug(`Response: ${JSON.stringify(response.data, null, 2)}`);
34673+
// Validate critical fields
34674+
if (!response.data.id) {
34675+
core.warning('⚠️ API response is missing id field');
34676+
core.warning(`Response status: ${response.status}`);
34677+
core.warning(`Response headers: ${JSON.stringify(response.headers)}`);
34678+
}
3467334679
return response.data;
3467434680
}
3467534681
catch (error) {
@@ -34747,13 +34753,15 @@ async function sendDeploymentEvent(apiUrl, apiKey, payload, failOnRejection = fa
3474734753
core.info('Continuing workflow (fail_on_rejection is false)');
3474834754
// Return a placeholder response when not failing
3474934755
return {
34750-
deployment_id: '',
34751-
event_id: '',
34756+
id: '',
3475234757
product_id: '',
34758+
product_name: '',
3475334759
version_id: '',
34760+
version: '',
3475434761
environment_id: '',
34762+
environment_name: '',
3475534763
status: 'rejected',
34756-
created_at: new Date().toISOString(),
34764+
deployed_at: new Date().toISOString(),
3475734765
};
3475834766
}
3475934767
}
@@ -35079,21 +35087,25 @@ function writeSummary(eventType, version, status, scmSha, apiUrl, resourceId, en
3507935087
const statusEmoji = getStatusEmoji(status);
3508035088
let summary = '## 🚀 Versioner Summary\n\n';
3508135089
if (eventType === 'build') {
35082-
const viewUrl = `${hostname}/manage/versions?view=${resourceId}`;
3508335090
summary += `- **Action:** Build\n`;
3508435091
summary += `- **Status:** ${statusEmoji} ${status}\n`;
3508535092
summary += `- **Version:** \`${version}\`\n`;
3508635093
summary += `- **Git SHA:** \`${scmSha}\`\n\n`;
35087-
summary += `<a href="${viewUrl}" target="_blank">View in Versioner →</a>\n`;
35094+
if (resourceId && resourceId !== 'undefined') {
35095+
const viewUrl = `${hostname}/manage/versions?view=${resourceId}`;
35096+
summary += `<a href="${viewUrl}" target="_blank">View in Versioner →</a>\n`;
35097+
}
3508835098
}
3508935099
else {
35090-
const viewUrl = `${hostname}/deployments/${resourceId}`;
3509135100
summary += `- **Action:** Deployment\n`;
3509235101
summary += `- **Environment:** ${environment}\n`;
3509335102
summary += `- **Status:** ${statusEmoji} ${status}\n`;
3509435103
summary += `- **Version:** \`${version}\`\n`;
3509535104
summary += `- **Git SHA:** \`${scmSha}\`\n\n`;
35096-
summary += `<a href="${viewUrl}" target="_blank">View in Versioner →</a>\n`;
35105+
if (resourceId && resourceId !== 'undefined') {
35106+
const viewUrl = `${hostname}/deployments/${resourceId}`;
35107+
summary += `<a href="${viewUrl}" target="_blank">View in Versioner →</a>\n`;
35108+
}
3509735109
}
3509835110
try {
3509935111
fs.appendFileSync(summaryPath, summary);
@@ -35196,19 +35208,25 @@ async function run() {
3519635208
};
3519735209
core.info('Sending deployment event to Versioner...');
3519835210
const response = await (0, api_client_1.sendDeploymentEvent)(inputs.apiUrl, inputs.apiKey, payload, inputs.failOnRejection);
35211+
// Validate response has required fields
35212+
if (!response.id) {
35213+
core.warning('⚠️ API response missing id field - this may indicate an API issue');
35214+
core.debug(`Full response: ${JSON.stringify(response, null, 2)}`);
35215+
}
3519935216
// Set outputs
35200-
core.setOutput('deployment_id', response.deployment_id);
35201-
core.setOutput('event_id', response.event_id);
35202-
core.setOutput('product_id', response.product_id);
35217+
core.setOutput('deployment_id', response.id || '');
35218+
core.setOutput('version_id', response.version_id || '');
35219+
core.setOutput('product_id', response.product_id || '');
35220+
core.setOutput('environment_id', response.environment_id || '');
3520335221
// Success summary
3520435222
core.info('');
3520535223
core.info(`✅ Deployment tracked successfully!`);
35206-
core.info(` Deployment ID: ${response.deployment_id}`);
35207-
core.info(` Event ID: ${response.event_id}`);
35224+
core.info(` Deployment ID: ${response.id || 'N/A'}`);
35225+
core.info(` Version ID: ${response.version_id || 'N/A'}`);
3520835226
// Create GitHub annotation for visibility
3520935227
core.notice(`Deployment tracked: ${productName}@${inputs.version} → ${inputs.environment} (${inputs.status})`);
3521035228
// Write to GitHub Step Summary
35211-
writeSummary('deployment', inputs.version, inputs.status, githubMetadata.scm_sha, inputs.apiUrl, response.deployment_id, inputs.environment);
35229+
writeSummary('deployment', inputs.version, inputs.status, githubMetadata.scm_sha, inputs.apiUrl, response.id, inputs.environment);
3521235230
// Fail the action if deployment status indicates failure
3521335231
const statusLower = inputs.status.toLowerCase();
3521435232
if (['failed', 'fail', 'failure', 'error'].includes(statusLower)) {

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types.d.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,23 @@ export interface BuildEventPayload {
4040
extra_metadata?: Record<string, unknown>;
4141
}
4242
export interface DeploymentEventResponse {
43-
deployment_id: string;
44-
event_id: string;
43+
id: string;
4544
product_id: string;
45+
product_name: string;
4646
version_id: string;
47+
version: string;
4748
environment_id: string;
49+
environment_name: string;
4850
status: string;
49-
created_at: string;
51+
deployed_at: string;
52+
source_system?: string | null;
53+
deployed_by?: string | null;
54+
deployed_by_name?: string | null;
55+
deployed_by_email?: string | null;
56+
completed_at?: string | null;
57+
deploy_url?: string | null;
58+
extra_metadata?: Record<string, unknown> | null;
59+
soak_time_hours?: number | null;
5060
}
5161
export interface BuildEventResponse {
5262
id: string;

dist/types.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api-client.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ export async function sendDeploymentEvent(
124124
core.info(`✅ Deployment event created successfully`)
125125
core.debug(`Response: ${JSON.stringify(response.data, null, 2)}`)
126126

127+
// Validate critical fields
128+
if (!response.data.id) {
129+
core.warning('⚠️ API response is missing id field')
130+
core.warning(`Response status: ${response.status}`)
131+
core.warning(`Response headers: ${JSON.stringify(response.headers)}`)
132+
}
133+
127134
return response.data
128135
} catch (error) {
129136
if (axios.isAxiosError(error)) {
@@ -223,13 +230,15 @@ export async function sendDeploymentEvent(
223230
core.info('Continuing workflow (fail_on_rejection is false)')
224231
// Return a placeholder response when not failing
225232
return {
226-
deployment_id: '',
227-
event_id: '',
233+
id: '',
228234
product_id: '',
235+
product_name: '',
229236
version_id: '',
237+
version: '',
230238
environment_id: '',
239+
environment_name: '',
231240
status: 'rejected',
232-
created_at: new Date().toISOString(),
241+
deployed_at: new Date().toISOString(),
233242
}
234243
}
235244
}

src/index.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,24 @@ function writeSummary(
8080
let summary = '## 🚀 Versioner Summary\n\n'
8181

8282
if (eventType === 'build') {
83-
const viewUrl = `${hostname}/manage/versions?view=${resourceId}`
8483
summary += `- **Action:** Build\n`
8584
summary += `- **Status:** ${statusEmoji} ${status}\n`
8685
summary += `- **Version:** \`${version}\`\n`
8786
summary += `- **Git SHA:** \`${scmSha}\`\n\n`
88-
summary += `<a href="${viewUrl}" target="_blank">View in Versioner →</a>\n`
87+
if (resourceId && resourceId !== 'undefined') {
88+
const viewUrl = `${hostname}/manage/versions?view=${resourceId}`
89+
summary += `<a href="${viewUrl}" target="_blank">View in Versioner →</a>\n`
90+
}
8991
} else {
90-
const viewUrl = `${hostname}/deployments/${resourceId}`
9192
summary += `- **Action:** Deployment\n`
9293
summary += `- **Environment:** ${environment}\n`
9394
summary += `- **Status:** ${statusEmoji} ${status}\n`
9495
summary += `- **Version:** \`${version}\`\n`
9596
summary += `- **Git SHA:** \`${scmSha}\`\n\n`
96-
summary += `<a href="${viewUrl}" target="_blank">View in Versioner →</a>\n`
97+
if (resourceId && resourceId !== 'undefined') {
98+
const viewUrl = `${hostname}/deployments/${resourceId}`
99+
summary += `<a href="${viewUrl}" target="_blank">View in Versioner →</a>\n`
100+
}
97101
}
98102

99103
try {
@@ -230,16 +234,23 @@ async function run(): Promise<void> {
230234
inputs.failOnRejection
231235
)
232236

237+
// Validate response has required fields
238+
if (!response.id) {
239+
core.warning('⚠️ API response missing id field - this may indicate an API issue')
240+
core.debug(`Full response: ${JSON.stringify(response, null, 2)}`)
241+
}
242+
233243
// Set outputs
234-
core.setOutput('deployment_id', response.deployment_id)
235-
core.setOutput('event_id', response.event_id)
236-
core.setOutput('product_id', response.product_id)
244+
core.setOutput('deployment_id', response.id || '')
245+
core.setOutput('version_id', response.version_id || '')
246+
core.setOutput('product_id', response.product_id || '')
247+
core.setOutput('environment_id', response.environment_id || '')
237248

238249
// Success summary
239250
core.info('')
240251
core.info(`✅ Deployment tracked successfully!`)
241-
core.info(` Deployment ID: ${response.deployment_id}`)
242-
core.info(` Event ID: ${response.event_id}`)
252+
core.info(` Deployment ID: ${response.id || 'N/A'}`)
253+
core.info(` Version ID: ${response.version_id || 'N/A'}`)
243254

244255
// Create GitHub annotation for visibility
245256
core.notice(
@@ -253,7 +264,7 @@ async function run(): Promise<void> {
253264
inputs.status,
254265
githubMetadata.scm_sha,
255266
inputs.apiUrl,
256-
response.deployment_id,
267+
response.id,
257268
inputs.environment
258269
)
259270

src/types.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,23 @@ export interface BuildEventPayload {
4343
}
4444

4545
export interface DeploymentEventResponse {
46-
deployment_id: string
47-
event_id: string
46+
id: string // Deployment ID (UUID)
4847
product_id: string
48+
product_name: string
4949
version_id: string
50+
version: string
5051
environment_id: string
52+
environment_name: string
5153
status: string
52-
created_at: string
54+
deployed_at: string
55+
source_system?: string | null
56+
deployed_by?: string | null
57+
deployed_by_name?: string | null
58+
deployed_by_email?: string | null
59+
completed_at?: string | null
60+
deploy_url?: string | null
61+
extra_metadata?: Record<string, unknown> | null
62+
soak_time_hours?: number | null
5363
}
5464

5565
export interface BuildEventResponse {

0 commit comments

Comments
 (0)