Skip to content

Commit 424b624

Browse files
committed
Refactor backport workflow to use context for label assignment
1 parent 6f7248b commit 424b624

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

.github/workflows/backport.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,25 @@ jobs:
2020
uses: actions/github-script@v6
2121
with:
2222
script: |
23+
const github = require('@actions/github');
24+
const context = github.context;
2325
const comment = context.payload.comment.body;
2426
const match = comment.match(/\/backport to release\/v(.*)/);
2527
2628
if (match) {
2729
const version = match[1];
2830
const label = `Backport-${version}.x-Consider`;
2931
console.log(label);
32+
33+
github.issues.addLabels({
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
issue_number: context.issue.number,
37+
labels: [label]
38+
});
3039
} else {
3140
throw new Error("No version found in comment");
3241
}
33-
34-
github.issues.addLabels({
35-
owner: context.repo.owner,
36-
repo: context.repo.repo,
37-
issue_number: context.issue.number,
38-
labels: [label]
39-
})
4042
backport:
4143
if: ${{ contains(github.event.comment.body, '/backport to') || github.event_name == 'schedule' }}
4244
uses: dotnet/arcade/.github/workflows/backport-base.yml@main

0 commit comments

Comments
 (0)