Skip to content

Commit fa2a39a

Browse files
authored
Update add-to-project.yml
1 parent 58ec268 commit fa2a39a

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

.github/workflows/add-to-project.yml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,40 @@ jobs:
2323
with:
2424
project-url: https://github.com/orgs/cantinilab/projects/2
2525
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
26-
# 2) (ISSUES) make/update label 'repo:<repo>'
27-
- name: Ensure repo label exists (issues)
26+
# 2) (ISSUES) add label to issue with repo name
27+
- name: Create/Update + apply repo label (issues)
2828
if: github.event_name == 'issues'
29-
uses: peter-evans/create-or-update-label@v4
29+
uses: actions/github-script@v7
3030
with:
31-
name: repo:${{ github.event.repository.name }}
32-
color: 666666
33-
description: Issue origin repository
31+
script: |
32+
const repoLabel = `repo:${context.repo.repo}`;
33+
34+
// ensure label exists (create if 404)
35+
try {
36+
await github.rest.issues.getLabel({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
name: repoLabel
40+
});
41+
} catch (e) {
42+
if (e.status === 404) {
43+
await github.rest.issues.createLabel({
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
name: repoLabel,
47+
color: '666666',
48+
description: 'Issue origin repository'
49+
});
50+
} else {
51+
throw e;
52+
}
53+
}
54+
55+
// add label to the issue
56+
await github.rest.issues.addLabels({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
issue_number: context.issue.number,
60+
labels: [repoLabel]
61+
});
3462

35-
# 3) (ISSUES) apply the label 'repo:<repo>' to the issue
36-
- name: Add repo label to issue
37-
if: github.event_name == 'issues'
38-
uses: actions-ecosystem/action-add-labels@v1
39-
with:
40-
github_token: ${{ secrets.GITHUB_TOKEN }}
41-
labels: repo:${{ github.event.repository.name }}

0 commit comments

Comments
 (0)