-
Notifications
You must be signed in to change notification settings - Fork 172
76 lines (65 loc) · 2.17 KB
/
update-release-project.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Update release project
on:
issues:
types: [opened, edited, labeled]
workflow_call:
defaults:
run:
shell: bash
jobs:
main:
name: Add relevant issue to the release project
runs-on: ubuntu-latest
steps:
- name: Get the latest release project
id: get-project-url
uses: actions/github-script@v7
with:
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
result-encoding: string
script: |
const query = `query ($login: String!) {
organization(login: $login) {
projectsV2(first: 100, orderBy: {direction: DESC, field: NUMBER}) {
nodes {
title
url
}
}
}
}`;
const projects = await github.graphql(query, {
login: context.repo.owner
});
const result = projects
.organization
.projectsV2
.nodes
.find(p => /zenoh [\w\.\-\+]+ release/i.test(p.title))
.url;
core.info(`Using release project ${result}`)
return result;
- name: Is the issue author a contributor?
id: author-is-contributor
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const contributors = await github.rest.repos.listContributors({
owner: context.repo.owner,
repo: context.repo.repo,
});
const login = "${{ github.event.issue.user.login }}";
const result = contributors
.data
.map(c => c.login)
.includes(login);
core.info(`Is the issue author ${login} a contributor? ${result}`);
return result;
- if: ${{ steps.author-is-contributor.outputs.result == 'true' }}
name: Add issue to the release project if it has a release label
uses: actions/[email protected]
with:
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
project-url: ${{ steps.get-project-url.outputs.result }}
labeled: release