-
Notifications
You must be signed in to change notification settings - Fork 5
49 lines (44 loc) · 1.57 KB
/
blank.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
name: Copy GitHub Labels
on:
workflow_dispatch:
jobs:
copy-labels:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Copy labels from another repository
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const sourceRepo = 'StephanAkkerman/fintwit-bot';
const targetOwner = context.repo.owner;
const targetRepo = context.repo.repo;
// Fetch labels from the source repository
const response = await github.rest.issues.listLabelsForRepo({
owner: sourceRepo.split('/')[0],
repo: sourceRepo.split('/')[1],
});
const labels = response.data;
// Create or update labels in the target repository
for (const label of labels) {
await github.rest.issues.createLabel({
owner: targetOwner,
repo: targetRepo,
name: label.name,
color: label.color,
description: label.description || '',
}).catch(error => {
// If label exists, update it
if (error.status === 422) {
github.rest.issues.updateLabel({
owner: targetOwner,
repo: targetRepo,
name: label.name,
color: label.color,
description: label.description || '',
});
}
});
}