Skip to content

Commit

Permalink
Merge branch 'main' into migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tianzhou committed Mar 14, 2024
2 parents d7104cd + a5ab4b9 commit 5071bc4
Show file tree
Hide file tree
Showing 13 changed files with 337 additions and 4,483 deletions.
75 changes: 61 additions & 14 deletions .github/actions/get-issue/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function run() {
headers = Object.assign({ "Content-Type": "application/json", Authorization: "Bearer " + token }, headers);
const issues = yield listAllIssues(`${url}/v1/projects/${projectId}/issues`, title);
// Sample issue
//
// {
// "name": "projects/example/issues/129",
// "uid": "129",
Expand Down Expand Up @@ -122,6 +123,66 @@ function run() {
}
core.info("Issue:\n" + JSON.stringify(issue, null, 2));
core.setOutput('issue', issue);
// Sample plan. A plan is the rollout blueprint containing stages, and each stage contains tasks.
//
// {
// "name": "projects/example/plans/132",
// "uid": "132",
// "issue": "",
// "title": "[bytebase/ci-example#6] chore: add migration files",
// "description": "Triggered by https://github.com/bytebase/ci-example/pull/6 chore: add migration files",
// "steps": [
// {
// "title": "",
// "specs": [
// {
// "earliestAllowedTime": null,
// "id": "b930f84c-6728-4145-818b-14d562ec0bc8",
// "changeDatabaseConfig": {
// "target": "instances/prod-instance/databases/example",
// "sheet": "projects/example/sheets/251",
// "type": "MIGRATE",
// "schemaVersion": "",
// "rollbackEnabled": false,
// "ghostFlags": {},
// "preUpdateBackupDetail": {
// "database": ""
// }
// }
// },
// {
// "earliestAllowedTime": null,
// "id": "8bec113c-1ae2-44e9-a85a-16b0844f7b9b",
// "changeDatabaseConfig": {
// "target": "instances/prod-instance/databases/example",
// "sheet": "projects/example/sheets/252",
// "type": "MIGRATE",
// "schemaVersion": "",
// "rollbackEnabled": false,
// "ghostFlags": {},
// "preUpdateBackupDetail": {
// "database": ""
// }
// }
// }
// ]
// }
// ]
// }
if (issue.plan) {
const components = issue.plan.split("/");
const planUid = components[components.length - 1];
const planRes = yield fetch(`${url}/v1/projects/${projectId}/plans/${planUid}`, {
method: "GET",
headers,
});
const planData = yield planRes.json();
if (planData.message) {
throw new Error(planData.message);
}
core.info("Plan:\n" + JSON.stringify(planData, null, 2));
core.setOutput('plan', planData);
}
// Sample rollout. A rollout contains one or multiple stages, and each stage contains multiple
// tasks. The task status field indicates whether that task has finished/failed/skipped.
//
Expand Down Expand Up @@ -171,20 +232,6 @@ function run() {
// }
// ]
// }
if (issue.plan) {
const components = issue.plan.split("/");
const planUid = components[components.length - 1];
const planRes = yield fetch(`${url}/v1/projects/${projectId}/plans/${planUid}`, {
method: "GET",
headers,
});
const planData = yield planRes.json();
if (planData.message) {
throw new Error(planData.message);
}
core.info("Plan:\n" + JSON.stringify(planData, null, 2));
core.setOutput('plan', planData);
}
if (issue.rollout) {
const components = issue.rollout.split("/");
const rolloutUid = components[components.length - 1];
Expand Down
79 changes: 62 additions & 17 deletions .github/actions/get-issue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function run(): Promise<void> {
const issues = await listAllIssues(`${url}/v1/projects/${projectId}/issues`, title);

// Sample issue

//
// {
// "name": "projects/example/issues/129",
// "uid": "129",
Expand Down Expand Up @@ -93,9 +93,69 @@ async function run(): Promise<void> {
core.info("Issue:\n" + JSON.stringify(issue, null, 2))
core.setOutput('issue', issue);

// Sample plan. A plan is the rollout blueprint containing stages, and each stage contains tasks.
//
// {
// "name": "projects/example/plans/132",
// "uid": "132",
// "issue": "",
// "title": "[bytebase/ci-example#6] chore: add migration files",
// "description": "Triggered by https://github.com/bytebase/ci-example/pull/6 chore: add migration files",
// "steps": [
// {
// "title": "",
// "specs": [
// {
// "earliestAllowedTime": null,
// "id": "b930f84c-6728-4145-818b-14d562ec0bc8",
// "changeDatabaseConfig": {
// "target": "instances/prod-instance/databases/example",
// "sheet": "projects/example/sheets/251",
// "type": "MIGRATE",
// "schemaVersion": "",
// "rollbackEnabled": false,
// "ghostFlags": {},
// "preUpdateBackupDetail": {
// "database": ""
// }
// }
// },
// {
// "earliestAllowedTime": null,
// "id": "8bec113c-1ae2-44e9-a85a-16b0844f7b9b",
// "changeDatabaseConfig": {
// "target": "instances/prod-instance/databases/example",
// "sheet": "projects/example/sheets/252",
// "type": "MIGRATE",
// "schemaVersion": "",
// "rollbackEnabled": false,
// "ghostFlags": {},
// "preUpdateBackupDetail": {
// "database": ""
// }
// }
// }
// ]
// }
// ]
// }
if (issue.plan) {
const components = issue.plan.split("/");
const planUid = components[components.length - 1];
const planRes = await fetch(`${url}/v1/projects/${projectId}/plans/${planUid}`, {
method: "GET",
headers,
});
const planData = await planRes.json();
if (planData.message) {
throw new Error(planData.message);
}
core.info("Plan:\n" + JSON.stringify(planData, null, 2))
core.setOutput('plan', planData);
}

// Sample rollout. A rollout contains one or multiple stages, and each stage contains multiple
// tasks. The task status field indicates whether that task has finished/failed/skipped.

//
// {
// "name": "projects/example/rollouts/122",
Expand Down Expand Up @@ -143,21 +203,6 @@ async function run(): Promise<void> {
// }
// ]
// }
if (issue.plan) {
const components = issue.plan.split("/");
const planUid = components[components.length - 1];
const planRes = await fetch(`${url}/v1/projects/${projectId}/plans/${planUid}`, {
method: "GET",
headers,
});
const planData = await planRes.json();
if (planData.message) {
throw new Error(planData.message);
}
core.info("Plan:\n" + JSON.stringify(planData, null, 2))
core.setOutput('plan', planData);
}

if (issue.rollout) {
const components = issue.rollout.split("/");
const rolloutUid = components[components.length - 1];
Expand Down
5 changes: 3 additions & 2 deletions .github/actions/search-issue/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This action should only be run on pull_request events.
# It will find the open issue created for the PR.
name: "Search Issue"
description: "Search the issue"
inputs:
Expand All @@ -17,6 +15,9 @@ inputs:
database:
description: "The name of database. Example: instances/prod-instance/databases/example"
required: true
# Current search API can't search multi-word text precisely, so it needs to be a single word.
title:
description: "The issue title"
outputs:
issues:
description: "The issue list matching the search criteria"
Expand Down
Loading

0 comments on commit 5071bc4

Please sign in to comment.