Skip to content

Commit 4dfa749

Browse files
authored
[SDK Breaking Change Labels] Flow head SHA through JS code (#36534)
1 parent b6f543b commit 4dfa749

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.github/workflows/sdk-breaking-change-labels.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
value: "${{ fromJson(steps.get-label-and-action.outputs.result).labelAction == 'add' }}"
6060
6161
- if: ${{ always() && fromJson(steps.get-label-and-action.outputs.result).headSha }}
62-
name: Upload artifact with issue number
62+
name: Upload artifact with head SHA
6363
uses: ./.github/actions/add-empty-artifact
6464
with:
6565
name: "head-sha"

.github/workflows/src/sdk-breaking-change-labels.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ export async function getLabelAndAction({ github, context, core }) {
3939
* @param {string} params.details_url
4040
* @param {typeof import("@actions/core")} params.core
4141
* @param {import('./retries.js').RetryOptions} [params.retryOptions]
42-
* @returns {Promise<{labelName: string | undefined, labelAction: LabelAction, issueNumber: number}>}
42+
* @returns {Promise<{labelName: string | undefined, labelAction: LabelAction, headSha: string, issueNumber: number}>}
4343
*/
4444
export async function getLabelAndActionImpl({ details_url, core, retryOptions = {} }) {
4545
// Override default logger from console.log to core.info
4646
retryOptions = { logger: core.info, ...retryOptions };
4747

48+
let head_sha = "";
4849
let issue_number = NaN;
4950
let labelAction;
5051
/** @type {String | undefined} */
@@ -74,6 +75,9 @@ export async function getLabelAndActionImpl({ details_url, core, retryOptions =
7475
// Parse the JSON data
7576
const specGenSdkArtifactInfo = JSON.parse(result.artifactData);
7677
const labelActionText = specGenSdkArtifactInfo.labelAction;
78+
79+
head_sha = specGenSdkArtifactInfo.headSha;
80+
7781
issue_number = parseInt(specGenSdkArtifactInfo.prNumber, 10);
7882
if (!issue_number) {
7983
core.warning(
@@ -100,5 +104,5 @@ export async function getLabelAndActionImpl({ details_url, core, retryOptions =
100104
labelAction = LabelAction.None;
101105
}
102106

103-
return { labelName, labelAction, issueNumber: issue_number };
107+
return { labelName, labelAction, headSha: head_sha, issueNumber: issue_number };
104108
}

.github/workflows/test/sdk-breaking-change-labels.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ describe("sdk-breaking-change-labels", () => {
188188
expect(result).toEqual({
189189
labelName: "",
190190
labelAction: LabelAction.None,
191+
headSha: "",
191192
issueNumber: NaN,
192193
});
193194

@@ -258,6 +259,7 @@ describe("sdk-breaking-change-labels", () => {
258259
expect(result).toEqual({
259260
labelName: "",
260261
labelAction: LabelAction.None,
262+
headSha: "",
261263
issueNumber: NaN,
262264
});
263265
});

0 commit comments

Comments
 (0)