Skip to content

Commit

Permalink
add tracked-in automation for dbaas and identity projects (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
seymourisdead authored Jul 22, 2024
1 parent 1d959b0 commit 530d584
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
54 changes: 52 additions & 2 deletions src/modules/engineering_projects_manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import {Issue} from "../../shared/issue";
import {
AUTOSCALING, COMPUTE,
CONSOLE,
CONTROL_PLANE, DATA, DOCS,
ENGINEERING, INFRA, PIXEL_POINT, POSTGRES, PRODUCT,
CONTROL_PLANE, DATA,
DBAAS,
DOCS,
ENGINEERING,
IDENTITY,
INFRA, PIXEL_POINT, POSTGRES, PRODUCT,
PRODUCT_DESIGN
} from "../../shared/project_ids";
import {Octokit} from "@octokit/core";
Expand Down Expand Up @@ -47,6 +51,12 @@ const FIELD_IDS_BY_PROJECT_ID = {
[PIXEL_POINT.projectId]: {
trackedIn: PIXEL_POINT.trackedInFieldId,
},
[IDENTITY.projectId]: {
trackedIn: IDENTITY.trackedInFieldId,
},
[DBAAS.projectId]: {
trackedIn: DBAAS.trackedInFieldId,
},
}

const updateTrackedInIfPossible = async (kit: Octokit, projectId: string, issue: Issue) => {
Expand Down Expand Up @@ -106,4 +116,44 @@ export const engineering_projects_manager_listener = (app: Probot) => {
logger("error", e);
}
});

// the code below is for running manually triggered syncs locally:
//
// 1. uncomment the code below and comment our code above, leave only this listener in the webhooks.js
// 2. create a temp field in the project where you want to update Tracked in field
// 3. build & run the bot
// 4. bulk update the temp field in the project
// 5. wait for the bot to update the Tracked in field
// 6. stop the bot
// 7. delete the temp field
// 8. Enjoy!
//
// app.on(["projects_v2_item.edited"], async (context) => {
// // we use this event instead issue.edited because in this event we will get the project_node_id
// if (!(Object.keys(FIELD_IDS_BY_PROJECT_ID))
// .includes(context.payload.projects_v2_item.project_node_id)
// ) {
// return;
// }
//
// if ((context.payload.changes.field_value.field_node_id === FIELD_IDS_BY_PROJECT_ID[context.payload.projects_v2_item.project_node_id].trackedIn)) {
// logger('info', 'skip because the tracked in value was changed')
// }
//
// const projectId = context.payload.projects_v2_item.project_node_id;
//
// try {
//
// let issue = await Issue.load(context.octokit, context.payload.projects_v2_item.content_node_id);
//
// await updateTrackedInIfPossible(context.octokit, projectId, issue);
//
// const children = await issue.getChildrenIssues(context.octokit);
// for (const childIssue of children) {
// await updateTrackedInIfPossible(context.octokit, projectId, childIssue);
// }
// } catch(e) {
// logger("error", e);
// }
// });
}
15 changes: 14 additions & 1 deletion src/shared/project_ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,17 @@ export const NEON_RELEASE_STATUS = {
projectId: 'PVT_kwDOBKF3Cs4AfDv2',
statusLastUpdatedFieldId: 'PVTF_lADOBKF3Cs4AfDv2zgZ0RRw',
statusFieldId: 'PVTSSF_lADOBKF3Cs4AfDv2zgUgpnk',
}
}

// project id: 95
export const IDENTITY = {
projectId: 'PVT_kwDOBKF3Cs4Ak_eq',
trackedInFieldId: 'PVTF_lADOBKF3Cs4Ak_eqzgdHTgc',
}

// project id: 87
export const DBAAS = {
projectId: 'PVT_kwDOBKF3Cs4AkjdS',
trackedInFieldId: 'PVTF_lADOBKF3Cs4AkjdSzgcvnTs',
}

0 comments on commit 530d584

Please sign in to comment.