Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Create webhook after repo config finishes
天舟077e944ada72
diff --git a/frontend/src/components/ProjectRepositorySetupPanel.vue b/frontend/src/components/ProjectRepositorySetupPanel.vueindex 8b7d519ce9..925bf36703 100644--- a/frontend/src/components/ProjectRepositorySetupPanel.vue+++ b/frontend/src/components/ProjectRepositorySetupPanel.vue@@ -51,7 +51,7 @@ export default {accessToken: "",repository: unknown("REPOSITORY") as Repository,baseDirectory: "",- branch: "",+ branchFilter: "",},});@@ -61,6 +61,14 @@ export default {const finishSetup = () => {console.log("finish", state.config);+ store+ .dispatch("gitlab/createWebhook", {+ vcs: state.config.vcs,+ projectId: state.config.repository.externalId,+ branchFilter: state.config.branchFilter,+ token: state.config.accessToken,+ })+ .then((createdHook) => {});};return {diff --git a/frontend/src/store/modules/gitlab.ts b/frontend/src/store/modules/gitlab.tsindex b5b3411c74..21b54bc2f7 100644--- a/frontend/src/store/modules/gitlab.ts+++ b/frontend/src/store/modules/gitlab.ts@@ -2,12 +2,13 @@ import axios from "axios";import { Repository, VCS } from "../../types";const GITLAB_API_PATH = "api/v4";+const GITLAB_WEBHOOK_PATH = "hook/gitlab";const getters = {};function convertGitLabProject(project: any): Repository {return {- id: project.id,+ externalId: project.id.toString(),name: project.name,fullPath: project.path_with_namespace,webURL: project.web_url,@@ -52,6 +53,37 @@ const actions = {return data.map((item: any) => convertGitLabProject(item));},++ // Create webhook to receive push event+ async createWebhook(+ {}: any,+ {+ vcs,+ projectId,+ branchFilter,+ token,+ }: { vcs: VCS; projectId: string; branchFilter: string; token: string }+ ): Promise<string> {+ const data = (+ await axios.post(+ `${vcs.instanceURL}/${GITLAB_API_PATH}/projects/${projectId}/hooks`,+ {+ url: `${vcs.instanceURL}/${GITLAB_WEBHOOK_PATH}`,+ push_events: true,+ push_events_branch_filter: branchFilter,+ // TODO: Be lax for now+ enable_ssl_verification: false,+ },+ {+ headers: {+ Authorization: "Bearer " + token,+ },+ }+ )+ ).data;++ return data.id.toString();+ },};const mutations = {};diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 277a55946f..430932dddb 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -318,7 +318,7 @@ export const unknown = (};const UNKONWN_REPOSITORY: Repository = {- id: UNKNOWN_ID,+ externalId: UNKNOWN_ID.toString(),name: "",fullPath: "",webURL: "",@@ -586,7 +586,7 @@ export const empty = (};const EMPTY_REPOSITORY: Repository = {- id: EMPTY_ID,+ externalId: EMPTY_ID.toString(),name: "",fullPath: "",webURL: "",diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.tsindex 3a2a697d72..9b4a59df06 100644--- a/frontend/src/types/project.ts+++ b/frontend/src/types/project.ts@@ -85,5 +85,5 @@ export type ProjectRepoConfig = {accessToken: string;repository: Repository;baseDirectory: string;- branch: string;+ branchFilter: string;};diff --git a/frontend/src/types/repository.ts b/frontend/src/types/repository.tsindex 49a9869996..fa600df3c1 100644--- a/frontend/src/types/repository.ts+++ b/frontend/src/types/repository.ts@@ -1,7 +1,6 @@-import { RepositoryId } from "./id";-export type Repository = {- id: RepositoryId;+ // e.g. In GitLab, this is the corresponding project id.+ externalId: string;// e.g. sample-projectname: string;// e.g. bytebase/sample-project