Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prerelease v1.0.3-alpha.2 #20

Merged
merged 5 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ exports.getPulls = async function (argv, prNumber) {
if (head && base) {
curHead = pulls.data[0].head.ref;
curBase = pulls.data[0].base.ref;
if (head == curHead && base == curBase) {
if (head == curHead && base == curBase && pulls.data[0].merged_at) {
break;
} else if (curHead == matchName.head && curBase == matchName.base) {
await closeIssue(argv, pulls.data[0].number, true);
Expand All @@ -142,11 +142,9 @@ exports.getPulls = async function (argv, prNumber) {
console.log('matchName', JSON.stringify(matchName));
if (!matchName.match) {
break;
} else if (!matchName.close) {
await closeIssue(argv, pulls.data[0].number, false);
break;
} else {
await closeIssue(argv, pulls.data[0].number, true);
}
if (pulls.data[0].merged_at) {
closeIssue(argv, pulls.data[0].number, !!matchName.close);
}
}
}
Expand All @@ -165,7 +163,28 @@ updateStatus = async function (mondayapi, boardId, itemId, status) {
console.log('empty itemId:', itemId);
return;
}
let query3 = `mutation{ change_column_value (board_id:${boardId}, item_id:${itemId}, column_id: "status", value: "{\\\"label\\\": \\\"${status}\\\"}"){id}}`;

const statusColumnId = await axios
.post(
'https://api.monday.com/v2',
JSON.stringify({
query: `query {boards (ids: ${boardId}) { columns { id title }}}`,
}),
{
headers: {
'Content-Type': 'application/json',
Authorization: mondayapi,
},
},
)
.then((res) => res.data?.data?.boards?.[0]?.columns.find((v) => v.title.toUpperCase().includes('STATUS'))?.id)
.catch(() => null);
if (!statusColumnId) {
return;
}
let query3 = `mutation{
change_column_value (board_id:${boardId}, item_id:${itemId}, column_id: ${statusColumnId}, value: "{\\\"label\\\": \\\"${status}\\\"}"){id}
}`;
// move_item_to_group (item_id: ${itemId}, group_id: ${groupId}) {
// id
// }
Expand All @@ -182,7 +201,7 @@ updateStatus = async function (mondayapi, boardId, itemId, status) {
},
},
);
console.log(`updateStatus to monday completed boardId: ${boardId} itemId: ${itemId}`);
console.log(`updateStatus to monday completed boardId: ${boardId} itemId: ${itemId} status:${status}`);
} catch (e) {
console.log('-------------------');
// throw new Error(`updateStatus to monday failed ${e.message}`);
Expand Down
35 changes: 27 additions & 8 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ exports.getPulls = async function (argv, prNumber) {
if (head && base) {
curHead = pulls.data[0].head.ref;
curBase = pulls.data[0].base.ref;
if (head == curHead && base == curBase) {
if (head == curHead && base == curBase && pulls.data[0].merged_at) {
break;
} else if (curHead == matchName.head && curBase == matchName.base) {
await closeIssue(argv, pulls.data[0].number, true);
Expand All @@ -136,11 +136,9 @@ exports.getPulls = async function (argv, prNumber) {
console.log('matchName', JSON.stringify(matchName));
if (!matchName.match) {
break;
} else if (!matchName.close) {
await closeIssue(argv, pulls.data[0].number, false);
break;
} else {
await closeIssue(argv, pulls.data[0].number, true);
}
if (pulls.data[0].merged_at) {
closeIssue(argv, pulls.data[0].number, !!matchName.close);
}
}
}
Expand All @@ -159,7 +157,28 @@ updateStatus = async function (mondayapi, boardId, itemId, status) {
console.log('empty itemId:', itemId);
return;
}
let query3 = `mutation{ change_column_value (board_id:${boardId}, item_id:${itemId}, column_id: "status", value: "{\\\"label\\\": \\\"${status}\\\"}"){id}}`;

const statusColumnId = await axios
.post(
'https://api.monday.com/v2',
JSON.stringify({
query: `query {boards (ids: ${boardId}) { columns { id title }}}`,
}),
{
headers: {
'Content-Type': 'application/json',
Authorization: mondayapi,
},
},
)
.then((res) => res.data?.data?.boards?.[0]?.columns.find((v) => v.title.toUpperCase().includes('STATUS'))?.id)
.catch(() => null);
if (!statusColumnId) {
return;
}
let query3 = `mutation{
change_column_value (board_id:${boardId}, item_id:${itemId}, column_id: ${statusColumnId}, value: "{\\\"label\\\": \\\"${status}\\\"}"){id}
}`;
// move_item_to_group (item_id: ${itemId}, group_id: ${groupId}) {
// id
// }
Expand All @@ -176,7 +195,7 @@ updateStatus = async function (mondayapi, boardId, itemId, status) {
},
},
);
console.log(`updateStatus to monday completed boardId: ${boardId} itemId: ${itemId}`);
console.log(`updateStatus to monday completed boardId: ${boardId} itemId: ${itemId} status:${status}`);
} catch (e) {
console.log('-------------------');
// throw new Error(`updateStatus to monday failed ${e.message}`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kungfu-trader/action-merge-close-issue",
"version": "1.0.3-alpha.1",
"version": "1.0.3-alpha.2",
"main": "dist/index.js",
"repository": "https://github.com/kungfu-trader/action-merge-close-issue",
"author": "Kungfu Trader",
Expand Down