Skip to content

Commit c2d79a6

Browse files
committed
Refactor column data retrieval in get-project-column-ids.yml to improve clarity and structure
1 parent c6f09da commit c2d79a6

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

.github/workflows/get-project-column-ids.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,40 +95,40 @@ jobs:
9595
return;
9696
}
9797
98-
let columnData = {};
98+
// Fetch columns for each project
99+
let columns = {};
99100
for (const [projectName, projectId] of Object.entries(projectIds)) {
100-
const query = `query($projectId: ID!) {
101+
const columnsQuery = `query($projectId: ID!) {
101102
node(id: $projectId) {
102103
... on ProjectV2 {
103104
fields(first: 10) {
104105
nodes {
105-
id
106-
name
106+
... on ProjectV2FieldConfiguration {
107+
id
108+
name
109+
}
107110
}
108111
}
109112
}
110113
}
111114
}`;
112115
113-
const result = await github.graphql(query, { projectId });
116+
const columnsResult = await github.graphql(columnsQuery, { projectId });
114117
115-
if (!result.node || !result.node.fields.nodes.length) {
116-
console.log(`❌ No columns found for Project ${projectName}.`);
117-
continue;
118+
if (columnsResult.node && columnsResult.node.fields.nodes.length) {
119+
columns[projectName] = columnsResult.node.fields.nodes.map(field => ({
120+
id: field.id,
121+
name: field.name
122+
}));
118123
}
119-
120-
columnData[projectName] = {};
121-
result.node.fields.nodes.forEach(field => {
122-
columnData[projectName][field.name] = field.id;
123-
});
124124
}
125125
126-
console.log("====== COLUMN IDs ======");
127-
Object.entries(columnData).forEach(([project, columns]) => {
128-
console.log(`Project "${project}":`);
129-
Object.entries(columns).forEach(([name, id]) => {
130-
console.log(` Column "${name}" = ID: "${id}"`);
126+
console.log("====== COLUMNS ======");
127+
Object.entries(columns).forEach(([projectName, columns]) => {
128+
console.log(`Project "${projectName}" Columns:`);
129+
columns.forEach(column => {
130+
console.log(` Column "${column.name}" = Column ID: "${column.id}"`);
131131
});
132132
});
133133
134-
core.setOutput("columns", JSON.stringify(columnData));
134+
core.setOutput("columns", JSON.stringify(columns));

0 commit comments

Comments
 (0)