forked from storyprotocol/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (48 loc) · 1.78 KB
/
sync-labels.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Sync Labels from Linear Issue to PR
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
sync-labels:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get associated issue number
id: get-issue-number
run: |
ISSUE_NUMBERS=$(echo "${{ github.event.pull_request.body }}" | grep -oE "#[0-9]+" | tr -d "#" | tr '\n' ',')
ISSUE_NUMBERS=$(echo $ISSUE_NUMBERS | sed 's/,$//')
echo "issue_numbers=$ISSUE_NUMBERS" >> $GITHUB_ENV
echo "Issue numbers are $ISSUE_NUMBERS"
- name: Get labels from issue
id: get_issue_labels
uses: actions/github-script@v7
with:
script: |
const issueNumbers = process.env.ISSUE_NUMBERS.split(",");
for (const issueNumber of issueNumbers) {
const { data: issue } = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
});
console.log(data);
const labels = issue.labels.map(label => label.name);
labels.forEach(label => allLabels.add(label));
}
env:
ISSUE_NUMBERS: ${{ env.issue_numbers }}
- name: Apply labels to PR
if: steps.get_issue_labels.outputs.result != ''
uses: actions/github-script@v6
with:
script: |
const labels = ${{env.labels}}.split(",");
echo `Applying labels: ${label.split(",")}`;
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels,
});