feat: gitlab triggers integration

This commit is contained in:
Krzysztof Dukszta-Kwiatkowski
2023-05-15 11:22:37 +02:00
committed by Ali BARIN
parent 93a2e2151e
commit 3f8f022d48
45 changed files with 2130 additions and 12 deletions

View File

@@ -0,0 +1,24 @@
import { IGlobalVariable } from '@automatisch/types';
import { URLSearchParams } from 'url';
export default async function generateAuthUrl($: IGlobalVariable) {
// ref: https://docs.gitlab.com/ee/api/oauth2.html#authorization-code-flow
const scopes = ['api', 'read_user'];
const searchParams = new URLSearchParams({
client_id: $.auth.data.clientId as string,
redirect_uri: $.auth.data.oAuthRedirectUrl as string,
scope: scopes.join(' '),
response_type: 'code',
state: `${Date.now()}`,
});
const url = `${
$.auth.data.oInstanceUrl
}/oauth/authorize?${searchParams.toString()}`;
await $.auth.set({
url,
});
}