forked from recodehive/recode-website
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (121 loc) · 4.64 KB
/
Copy pathautolabler.yml
File metadata and controls
139 lines (121 loc) · 4.64 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Auto Label Issues and PRs
on:
pull_request_target:
types: [opened]
issues:
types: [opened]
permissions:
issues: write
pull-requests: write
repository-projects: write
jobs:
add-labels:
runs-on: ubuntu-latest
steps:
- name: Add labels to PR
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
await github.rest.issues.addLabels({
...context.repo,
issue_number: prNumber,
labels: ["in-review", "level 1", "recode"]
});
console.log(`Added labels [in-review, level 1, recode] to PR #${prNumber}`);
- name: Set Milestone on PR
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const milestoneName = "recode:launch 3.0";
const { data: milestones } = await github.rest.issues.listMilestones({
...context.repo,
state: "open",
per_page: 100
});
const milestone = milestones.find(m => m.title === milestoneName);
if (milestone) {
await github.rest.issues.update({
...context.repo,
issue_number: prNumber,
milestone: milestone.number
});
console.log(`Set milestone '${milestoneName}' (number: ${milestone.number}) on PR #${prNumber}`);
} else {
console.log(`Milestone '${milestoneName}' not found; skipping.`);
}
- name: Add PR to Projects
if: github.event_name == 'pull_request_target'
continue-on-error: true
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
script: |
const prNodeId = context.payload.pull_request.node_id;
const owner = context.repo.owner;
const projectNames = ["@recode-web", "Recode Public Roadmap"];
// Query organization projects (Projects v2)
const query = `
query($owner: String!) {
organization(login: $owner) {
projectsV2(first: 100) {
nodes {
id
title
}
}
}
}
`;
let projects = [];
try {
const result = await github.graphql(query, { owner });
projects = result.organization.projectsV2.nodes;
} catch (err) {
console.log(`Could not fetch org projects: ${err.message}`);
}
for (const projectName of projectNames) {
const project = projects.find(p => p.title === projectName);
if (project) {
try {
await github.graphql(`
mutation($projectId: ID!, $contentId: ID!) {
addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) {
item { id }
}
}
`, { projectId: project.id, contentId: prNodeId });
console.log(`Added PR to project '${projectName}'`);
} catch (err) {
console.log(`Could not add PR to project '${projectName}': ${err.message}`);
}
} else {
console.log(`Project '${projectName}' not found; skipping.`);
}
}
- name: Add labels to Issue
if: github.event_name == 'issues'
uses: actions/github-script@v7
with:
script: |
const issueNumber = context.payload.issue.number;
await github.rest.issues.addLabels({
...context.repo,
issue_number: issueNumber,
labels: ["recode", "level 1"]
});
console.log(`Added labels [recode, level 1] to Issue #${issueNumber}`);
- name: Set Issue Type to Bug
if: github.event_name == 'issues'
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
REPO=${{ github.repository }}
TOKEN=${{ secrets.GITHUB_TOKEN }}
curl --request PATCH \
--url https://api.github.com/repos/${REPO}/issues/${ISSUE_NUMBER} \
--header "authorization: token ${TOKEN}" \
--header "content-type: application/json" \
--data '{"type":"Bug"}'