Skip to content

Commit 23961e2

Browse files
Output branch name
Output the name of the branch created when a pull request to update the .NET SDK is opened.
1 parent 0bf1e5b commit 23961e2

9 files changed

Lines changed: 18 additions & 3 deletions

File tree

.github/workflows/update-dotnet-sdk-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ jobs:
3232
echo "SDK updated: ${{ needs.update-sdk.outputs.sdk-updated }}"
3333
echo "SDK version: ${{ needs.update-sdk.outputs.sdk-version }}"
3434
echo "Security: ${{ needs.update-sdk.outputs.security }}"
35+
echo "Branch name: ${{ needs.update-sdk.outputs.branch-name }}"
3536
echo "PR number: ${{ needs.update-sdk.outputs.pull-request-number }}"
3637
echo "PR URL: ${{ needs.update-sdk.outputs.pull-request-html-url }}"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ jobs:
200200

201201
| **Name** | **Description** |
202202
|:--|:--|
203+
| `branch-name` | The name of the Git branch associated with the Pull Request created by the action if the .NET SDK is updated. |
203204
| `pull-request-number` | The number of the Pull Request created by the action if the .NET SDK is updated. |
204205
| `pull-request-html-url` | The HTML URL of the Pull Request created by the action if the .NET SDK is updated. |
205206
| `sdk-updated` | Whether the .NET SDK was updated by the action. |

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ inputs:
4545
required: false
4646
default: false
4747
outputs:
48+
branch-name:
49+
description: 'The name of the Git branch associated with the Pull Request created by the action if the .NET SDK is updated.'
4850
pull-request-number:
4951
description: 'The number of the Pull Request created by the action if the .NET SDK is updated.'
5052
pull-request-html-url:

dist/index.js

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.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/DotNetSdkUpdater.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export class DotNetSdkUpdater {
184184
const update = DotNetSdkUpdater.getLatestRelease(sdkVersion, releaseChannel);
185185

186186
const result: UpdateResult = {
187+
branchName: '',
187188
pullRequestNumber: 0,
188189
pullRequestUrl: '',
189190
updated: false,
@@ -202,6 +203,7 @@ export class DotNetSdkUpdater {
202203

203204
if (baseBranch) {
204205
const pullRequest = await this.createPullRequest(baseBranch, update);
206+
result.branchName = pullRequest.branch;
205207
result.pullRequestNumber = pullRequest.number;
206208
result.pullRequestUrl = pullRequest.url;
207209

@@ -249,6 +251,7 @@ export class DotNetSdkUpdater {
249251
if (this.options.dryRun) {
250252
core.info(`Skipped creating GitHub Pull Request for branch ${this.options.branch} to ${base}`);
251253
return {
254+
branch: '',
252255
number: 0,
253256
url: '',
254257
};
@@ -262,6 +265,7 @@ export class DotNetSdkUpdater {
262265
core.info(`View the pull request at ${response.data.html_url}`);
263266

264267
const result = {
268+
branch: response.data.head.ref,
265269
number: response.data.number,
266270
url: response.data.html_url,
267271
};
@@ -476,6 +480,7 @@ interface CveInfo {
476480
}
477481

478482
interface PullRequest {
483+
branch: string;
479484
number: number;
480485
url: string;
481486
}

src/UpdateResult.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.
33

44
export interface UpdateResult {
5+
branchName: string;
56
pullRequestNumber: number;
67
pullRequestUrl: string;
78
security: boolean;

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export async function run(): Promise<void> {
4343
const updater = new DotNetSdkUpdater(options);
4444
const result = await updater.tryUpdateSdk();
4545

46+
core.setOutput('branch-name', result.branchName);
4647
core.setOutput('pull-request-number', result.pullRequestNumber);
4748
core.setOutput('pull-request-html-url', result.pullRequestUrl);
4849
core.setOutput('sdk-updated', result.updated);

tests/main.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ describe('update-dotnet-sdk tests', () => {
6868
Promise.resolve({
6969
data: {
7070
number: '42',
71-
html_url: 'https://github.local/martincostello/update-dotnet-sdk/pull/42'
71+
html_url: 'https://github.local/martincostello/update-dotnet-sdk/pull/42',
72+
head: {
73+
ref: 'update-dotnet-sdk-3.1.201'
74+
}
7275
}
7376
})
7477
}
@@ -80,6 +83,7 @@ describe('update-dotnet-sdk tests', () => {
8083
expect(core.error).toHaveBeenCalledTimes(0);
8184
expect(core.setFailed).toHaveBeenCalledTimes(0);
8285

86+
assertOutputValue('branch-name', 'update-dotnet-sdk-3.1.201');
8387
assertOutputValue('pull-request-html-url', 'https://github.local/martincostello/update-dotnet-sdk/pull/42');
8488
assertOutputValue('pull-request-number', '42');
8589
assertOutputValue('sdk-updated', 'true');

0 commit comments

Comments
 (0)