Compare commits
6 Commits
custom-dep
...
AUT-960
Author | SHA1 | Date | |
---|---|---|---|
![]() |
93fdc05529 | ||
![]() |
3e6f22748b | ||
![]() |
fbd62d8635 | ||
![]() |
b8ac73478b | ||
![]() |
f8018ca384 | ||
![]() |
99025c6a7c |
102
packages/backend/src/apps/gitea/actions/create-issue/index.js
Normal file
102
packages/backend/src/apps/gitea/actions/create-issue/index.js
Normal file
@@ -0,0 +1,102 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create issue',
|
||||
key: 'createIssue',
|
||||
description: 'Creates a new issue.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Repo',
|
||||
key: 'repo',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listRepos',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Body',
|
||||
key: 'body',
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Labels',
|
||||
key: 'labels',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
fields: [
|
||||
{
|
||||
label: 'Label',
|
||||
key: 'label',
|
||||
type: 'dropdown',
|
||||
description: 'Only trigger on issues when this label is added.',
|
||||
required: false,
|
||||
variables: true,
|
||||
dependsOn: ['parameters.repo'],
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listLabels',
|
||||
},
|
||||
{
|
||||
name: 'parameters.repo',
|
||||
value: '{parameters.repo}',
|
||||
},
|
||||
{
|
||||
name: 'parameters.showLabelId',
|
||||
value: 'true',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const repoOwner = $.auth.data.repoOwner;
|
||||
const repo = $.step.parameters.repo;
|
||||
const title = $.step.parameters.title;
|
||||
const issueBody = $.step.parameters.body;
|
||||
const allLabels = $.step.parameters.labels;
|
||||
const formattedAllLabels = allLabels
|
||||
.filter((label) => label.label !== '')
|
||||
.map((label) => label.label);
|
||||
|
||||
const body = {
|
||||
title,
|
||||
body: issueBody,
|
||||
};
|
||||
|
||||
if (formattedAllLabels.length) {
|
||||
body.labels = formattedAllLabels;
|
||||
}
|
||||
|
||||
const response = await $.http.post(
|
||||
`/repos/${repoOwner}/${repo}/issues`,
|
||||
body
|
||||
);
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
||||
});
|
3
packages/backend/src/apps/gitea/actions/index.js
Normal file
3
packages/backend/src/apps/gitea/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import createIssue from './create-issue/index.js';
|
||||
|
||||
export default [createIssue];
|
1
packages/backend/src/apps/gitea/assets/favicon.svg
Normal file
1
packages/backend/src/apps/gitea/assets/favicon.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" style="enable-background:new 0 0 640 640" xml:space="preserve" width="32" height="32"><path style="fill:#fff" d="m395.9 484.2-126.9-61c-12.5-6-17.9-21.2-11.8-33.8l61-126.9c6-12.5 21.2-17.9 33.8-11.8 17.2 8.3 27.1 13 27.1 13l-.1-109.2 16.7-.1.1 117.1s57.4 24.2 83.1 40.1c3.7 2.3 10.2 6.8 12.9 14.4 2.1 6.1 2 13.1-1 19.3l-61 126.9c-6.2 12.7-21.4 18.1-33.9 12z"/><path style="fill:#609926" d="M622.7 149.8c-4.1-4.1-9.6-4-9.6-4s-117.2 6.6-177.9 8c-13.3.3-26.5.6-39.6.7v117.2c-5.5-2.6-11.1-5.3-16.6-7.9 0-36.4-.1-109.2-.1-109.2-29 .4-89.2-2.2-89.2-2.2s-141.4-7.1-156.8-8.5c-9.8-.6-22.5-2.1-39 1.5-8.7 1.8-33.5 7.4-53.8 26.9C-4.9 212.4 6.6 276.2 8 285.8c1.7 11.7 6.9 44.2 31.7 72.5 45.8 56.1 144.4 54.8 144.4 54.8s12.1 28.9 30.6 55.5c25 33.1 50.7 58.9 75.7 62 63 0 188.9-.1 188.9-.1s12 .1 28.3-10.3c14-8.5 26.5-23.4 26.5-23.4S547 483 565 451.5c5.5-9.7 10.1-19.1 14.1-28 0 0 55.2-117.1 55.2-231.1-1.1-34.5-9.6-40.6-11.6-42.6zM125.6 353.9c-25.9-8.5-36.9-18.7-36.9-18.7S69.6 321.8 60 295.4c-16.5-44.2-1.4-71.2-1.4-71.2s8.4-22.5 38.5-30c13.8-3.7 31-3.1 31-3.1s7.1 59.4 15.7 94.2c7.2 29.2 24.8 77.7 24.8 77.7s-26.1-3.1-43-9.1zm300.3 107.6s-6.1 14.5-19.6 15.4c-5.8.4-10.3-1.2-10.3-1.2s-.3-.1-5.3-2.1l-112.9-55s-10.9-5.7-12.8-15.6c-2.2-8.1 2.7-18.1 2.7-18.1L322 273s4.8-9.7 12.2-13c.6-.3 2.3-1 4.5-1.5 8.1-2.1 18 2.8 18 2.8L467.4 315s12.6 5.7 15.3 16.2c1.9 7.4-.5 14-1.8 17.2-6.3 15.4-55 113.1-55 113.1z"/><path style="fill:#609926" d="M326.8 380.1c-8.2.1-15.4 5.8-17.3 13.8-1.9 8 2 16.3 9.1 20 7.7 4 17.5 1.8 22.7-5.4 5.1-7.1 4.3-16.9-1.8-23.1l24-49.1c1.5.1 3.7.2 6.2-.5 4.1-.9 7.1-3.6 7.1-3.6 4.2 1.8 8.6 3.8 13.2 6.1 4.8 2.4 9.3 4.9 13.4 7.3.9.5 1.8 1.1 2.8 1.9 1.6 1.3 3.4 3.1 4.7 5.5 1.9 5.5-1.9 14.9-1.9 14.9-2.3 7.6-18.4 40.6-18.4 40.6-8.1-.2-15.3 5-17.7 12.5-2.6 8.1 1.1 17.3 8.9 21.3 7.8 4 17.4 1.7 22.5-5.3 5-6.8 4.6-16.3-1.1-22.6 1.9-3.7 3.7-7.4 5.6-11.3 5-10.4 13.5-30.4 13.5-30.4.9-1.7 5.7-10.3 2.7-21.3-2.5-11.4-12.6-16.7-12.6-16.7-12.2-7.9-29.2-15.2-29.2-15.2s0-4.1-1.1-7.1c-1.1-3.1-2.8-5.1-3.9-6.3 4.7-9.7 9.4-19.3 14.1-29-4.1-2-8.1-4-12.2-6.1-4.8 9.8-9.7 19.7-14.5 29.5-6.7-.1-12.9 3.5-16.1 9.4-3.4 6.3-2.7 14.1 1.9 19.8l-24.6 50.4z"/></svg>
|
After Width: | Height: | Size: 2.2 KiB |
24
packages/backend/src/apps/gitea/auth/generate-auth-url.js
Normal file
24
packages/backend/src/apps/gitea/auth/generate-auth-url.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { URLSearchParams } from 'url';
|
||||
|
||||
export default async function generateAuthUrl($) {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value;
|
||||
const state = Math.random().toString();
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId,
|
||||
redirect_uri: redirectUri,
|
||||
response_type: 'code',
|
||||
state: state,
|
||||
});
|
||||
|
||||
const url = `${
|
||||
$.auth.data.instanceUrl
|
||||
}/login/oauth/authorize?${searchParams.toString()}`;
|
||||
|
||||
await $.auth.set({
|
||||
url,
|
||||
originalState: state,
|
||||
});
|
||||
}
|
59
packages/backend/src/apps/gitea/auth/index.js
Normal file
59
packages/backend/src/apps/gitea/auth/index.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import generateAuthUrl from './generate-auth-url.js';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import refreshToken from './refresh-token.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'oAuthRedirectUrl',
|
||||
label: 'OAuth Redirect URL',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: true,
|
||||
value: '{WEB_APP_URL}/app/gitea/connections/add',
|
||||
placeholder: null,
|
||||
description:
|
||||
'When asked to input a redirect URL in Gitea, enter the URL above.',
|
||||
clickToCopy: true,
|
||||
},
|
||||
{
|
||||
key: 'instanceUrl',
|
||||
label: 'Instance URL',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'Client ID',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'clientSecret',
|
||||
label: 'Client Secret',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
|
||||
generateAuthUrl,
|
||||
verifyCredentials,
|
||||
isStillVerified,
|
||||
refreshToken,
|
||||
};
|
@@ -0,0 +1,8 @@
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
const currentUser = await getCurrentUser($);
|
||||
return !!currentUser.email;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
29
packages/backend/src/apps/gitea/auth/refresh-token.js
Normal file
29
packages/backend/src/apps/gitea/auth/refresh-token.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { URLSearchParams } from 'node:url';
|
||||
|
||||
const refreshToken = async ($) => {
|
||||
const params = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
grant_type: 'refresh_token',
|
||||
refresh_token: $.auth.data.refreshToken,
|
||||
});
|
||||
|
||||
const { data } = await $.http.post(
|
||||
`${$.auth.data.instanceUrl}/login/oauth/access_token`,
|
||||
params.toString(),
|
||||
{
|
||||
additionalProperties: {
|
||||
skipAddingBaseUrl: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await $.auth.set({
|
||||
accessToken: data.access_token,
|
||||
expiresIn: data.expires_in,
|
||||
tokenType: data.token_type,
|
||||
refreshToken: data.refresh_token,
|
||||
});
|
||||
};
|
||||
|
||||
export default refreshToken;
|
50
packages/backend/src/apps/gitea/auth/verify-credentials.js
Normal file
50
packages/backend/src/apps/gitea/auth/verify-credentials.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
import { URLSearchParams } from 'url';
|
||||
|
||||
const verifyCredentials = async ($) => {
|
||||
if ($.auth.data.originalState !== $.auth.data.state) {
|
||||
throw new Error(`The 'state' parameter does not match.`);
|
||||
}
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value;
|
||||
const params = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
code: $.auth.data.code,
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
|
||||
const { data } = await $.http.post(
|
||||
`${$.auth.data.instanceUrl}/login/oauth/access_token`,
|
||||
params.toString(),
|
||||
{
|
||||
additionalProperties: {
|
||||
skipAddingBaseUrl: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await $.auth.set({
|
||||
accessToken: data.access_token,
|
||||
tokenType: data.token_type,
|
||||
});
|
||||
|
||||
const currentUser = await getCurrentUser($);
|
||||
const screenName = [currentUser.username, currentUser.email]
|
||||
.filter(Boolean)
|
||||
.join(' @ ');
|
||||
|
||||
await $.auth.set({
|
||||
clientId: $.auth.data.clientId,
|
||||
clientSecret: $.auth.data.clientSecret,
|
||||
expiresIn: data.expires_in,
|
||||
refreshToken: data.refresh_token,
|
||||
repoOwner: currentUser.username,
|
||||
screenName,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -0,0 +1,9 @@
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.accessToken) {
|
||||
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -0,0 +1,6 @@
|
||||
const getCurrentUser = async ($) => {
|
||||
const { data: currentUser } = await $.http.get(`/user`);
|
||||
return currentUser;
|
||||
};
|
||||
|
||||
export default getCurrentUser;
|
14
packages/backend/src/apps/gitea/common/set-base-url.js
Normal file
14
packages/backend/src/apps/gitea/common/set-base-url.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const setBaseUrl = ($, requestConfig) => {
|
||||
if (requestConfig.additionalProperties?.skipAddingBaseUrl)
|
||||
return requestConfig;
|
||||
|
||||
const instanceUrl = $.auth.data.instanceUrl;
|
||||
|
||||
if (instanceUrl) {
|
||||
requestConfig.baseURL = `${instanceUrl}/api/v1`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default setBaseUrl;
|
4
packages/backend/src/apps/gitea/dynamic-data/index.js
Normal file
4
packages/backend/src/apps/gitea/dynamic-data/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import listLabels from './list-labels/index.js';
|
||||
import listRepos from './list-repos/index.js';
|
||||
|
||||
export default [listLabels, listRepos];
|
@@ -0,0 +1,42 @@
|
||||
export default {
|
||||
name: 'List labels',
|
||||
key: 'listLabels',
|
||||
|
||||
async run($) {
|
||||
const labels = {
|
||||
data: [],
|
||||
};
|
||||
const repoOwner = $.auth.data.repoOwner;
|
||||
const repo = $.step.parameters.repo;
|
||||
const showLabelId = $.step.parameters.showLabelId === 'true';
|
||||
|
||||
const params = {
|
||||
page: 1,
|
||||
limit: 100,
|
||||
};
|
||||
|
||||
let totalCount;
|
||||
let totalRequestedCount;
|
||||
do {
|
||||
const { data, headers } = await $.http.get(
|
||||
`/repos/${repoOwner}/${repo}/labels`,
|
||||
{ params }
|
||||
);
|
||||
params.page = params.page + 1;
|
||||
totalCount = Number(headers['x-total-count']);
|
||||
totalRequestedCount = params.page * params.limit;
|
||||
|
||||
if (data?.length) {
|
||||
for (const label of data) {
|
||||
const value = showLabelId ? label.id : label.name;
|
||||
labels.data.push({
|
||||
value,
|
||||
name: label.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (totalRequestedCount <= totalCount);
|
||||
|
||||
return labels;
|
||||
},
|
||||
};
|
@@ -0,0 +1,35 @@
|
||||
export default {
|
||||
name: 'List repos',
|
||||
key: 'listRepos',
|
||||
|
||||
async run($) {
|
||||
const repos = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
page: 1,
|
||||
limit: 100,
|
||||
};
|
||||
|
||||
let totalCount;
|
||||
let totalRequestedCount;
|
||||
do {
|
||||
const { data, headers } = await $.http.get('/user/repos', { params });
|
||||
params.page = params.page + 1;
|
||||
totalCount = Number(headers['x-total-count']);
|
||||
totalRequestedCount = params.page * params.limit;
|
||||
|
||||
if (data?.length) {
|
||||
for (const repo of data) {
|
||||
repos.data.push({
|
||||
value: repo.name,
|
||||
name: repo.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (totalRequestedCount <= totalCount);
|
||||
|
||||
return repos;
|
||||
},
|
||||
};
|
23
packages/backend/src/apps/gitea/index.js
Normal file
23
packages/backend/src/apps/gitea/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import setBaseUrl from './common/set-base-url.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Gitea',
|
||||
key: 'gitea',
|
||||
iconUrl: '{BASE_URL}/apps/gitea/assets/favicon.svg',
|
||||
authDocUrl: '{DOCS_URL}/apps/gitea/connection',
|
||||
supportsConnections: true,
|
||||
baseUrl: '',
|
||||
apiBaseUrl: '',
|
||||
primaryColor: '609926',
|
||||
beforeRequest: [setBaseUrl, addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
dynamicData,
|
||||
actions,
|
||||
});
|
5
packages/backend/src/apps/gitea/triggers/index.js
Normal file
5
packages/backend/src/apps/gitea/triggers/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import newIssues from './new-issues/index.js';
|
||||
import newStargazers from './new-stargazers/index.js';
|
||||
import newWatchers from './new-watchers/index.js';
|
||||
|
||||
export default [newIssues, newStargazers, newWatchers];
|
121
packages/backend/src/apps/gitea/triggers/new-issues/index.js
Normal file
121
packages/backend/src/apps/gitea/triggers/new-issues/index.js
Normal file
@@ -0,0 +1,121 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New issues',
|
||||
key: 'newIssues',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a new issue is created.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Repo',
|
||||
key: 'repo',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listRepos',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Which types of issues should this trigger on?',
|
||||
key: 'issueType',
|
||||
type: 'dropdown',
|
||||
description: 'Defaults to any issue you can see.',
|
||||
required: true,
|
||||
variables: true,
|
||||
value: 'all',
|
||||
options: [
|
||||
{
|
||||
label: 'Closed',
|
||||
value: 'closed',
|
||||
},
|
||||
{
|
||||
label: 'Open',
|
||||
value: 'open',
|
||||
},
|
||||
{
|
||||
label: 'All',
|
||||
value: 'all',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Labels',
|
||||
key: 'labels',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
fields: [
|
||||
{
|
||||
label: 'Label',
|
||||
key: 'label',
|
||||
type: 'dropdown',
|
||||
description: 'Only trigger on issues when this label is added.',
|
||||
required: false,
|
||||
variables: true,
|
||||
dependsOn: ['parameters.repo'],
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listLabels',
|
||||
},
|
||||
{
|
||||
name: 'parameters.repo',
|
||||
value: '{parameters.repo}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const repo = $.step.parameters.repo;
|
||||
const issueType = $.step.parameters.issueType;
|
||||
const allLabels = $.step.parameters.labels;
|
||||
const formattedAllLabels = allLabels.map((label) => label.label).join(',');
|
||||
const repoOwner = $.auth.data.repoOwner;
|
||||
|
||||
const params = {
|
||||
page: 1,
|
||||
limit: 100,
|
||||
state: issueType,
|
||||
labels: formattedAllLabels,
|
||||
};
|
||||
|
||||
let totalCount;
|
||||
let totalRequestedCount;
|
||||
do {
|
||||
const { data, headers } = await $.http.get(
|
||||
`/repos/${repoOwner}/${repo}/issues`,
|
||||
{
|
||||
params,
|
||||
}
|
||||
);
|
||||
params.page = params.page + 1;
|
||||
totalCount = Number(headers['x-total-count']);
|
||||
totalRequestedCount = params.page * params.limit;
|
||||
|
||||
if (data?.length) {
|
||||
for (const issue of data) {
|
||||
$.pushTriggerItem({
|
||||
raw: issue,
|
||||
meta: {
|
||||
internalId: issue.id.toString(),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (totalRequestedCount <= totalCount);
|
||||
},
|
||||
});
|
@@ -0,0 +1,61 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New stargazers',
|
||||
key: 'newStargazers',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a user stars a repository.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Repo',
|
||||
key: 'repo',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listRepos',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const repo = $.step.parameters.repo;
|
||||
const repoOwner = $.auth.data.repoOwner;
|
||||
const params = {
|
||||
page: 1,
|
||||
limit: 100,
|
||||
};
|
||||
|
||||
let totalCount;
|
||||
let totalRequestedCount;
|
||||
do {
|
||||
const { data, headers } = await $.http.get(
|
||||
`/repos/${repoOwner}/${repo}/stargazers`,
|
||||
{
|
||||
params,
|
||||
}
|
||||
);
|
||||
params.page = params.page + 1;
|
||||
totalCount = Number(headers['x-total-count']);
|
||||
totalRequestedCount = params.page * params.limit;
|
||||
|
||||
if (data?.length) {
|
||||
for (const stargazer of data) {
|
||||
$.pushTriggerItem({
|
||||
raw: stargazer,
|
||||
meta: {
|
||||
internalId: stargazer.id.toString(),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (totalRequestedCount <= totalCount);
|
||||
},
|
||||
});
|
@@ -0,0 +1,61 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New watchers',
|
||||
key: 'newWatchers',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a user watches a repository.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Repo',
|
||||
key: 'repo',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listRepos',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const repo = $.step.parameters.repo;
|
||||
const repoOwner = $.auth.data.repoOwner;
|
||||
const params = {
|
||||
page: 1,
|
||||
limit: 100,
|
||||
};
|
||||
|
||||
let totalCount;
|
||||
let totalRequestedCount;
|
||||
do {
|
||||
const { data, headers } = await $.http.get(
|
||||
`/repos/${repoOwner}/${repo}/subscribers`,
|
||||
{
|
||||
params,
|
||||
}
|
||||
);
|
||||
params.page = params.page + 1;
|
||||
totalCount = Number(headers['x-total-count']);
|
||||
totalRequestedCount = params.page * params.limit;
|
||||
|
||||
if (data?.length) {
|
||||
for (const subscriber of data) {
|
||||
$.pushTriggerItem({
|
||||
raw: subscriber,
|
||||
meta: {
|
||||
internalId: subscriber.id.toString(),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (totalRequestedCount <= totalCount);
|
||||
},
|
||||
});
|
@@ -122,6 +122,16 @@ export default defineConfig({
|
||||
{ text: 'Connection', link: '/apps/ghost/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Gitea',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/gitea/triggers' },
|
||||
{ text: 'Actions', link: '/apps/gitea/actions' },
|
||||
{ text: 'Connection', link: '/apps/gitea/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'GitHub',
|
||||
collapsible: true,
|
||||
|
12
packages/docs/pages/apps/gitea/actions.md
Normal file
12
packages/docs/pages/apps/gitea/actions.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
favicon: /favicons/gitea.svg
|
||||
items:
|
||||
- name: Create issue
|
||||
desc: Creates a new issue.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
16
packages/docs/pages/apps/gitea/connection.md
Normal file
16
packages/docs/pages/apps/gitea/connection.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Gitea
|
||||
|
||||
:::info
|
||||
This page explains the steps you need to follow to set up the Gitea
|
||||
connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||
:::
|
||||
|
||||
1. Go to your Gitea Settings panel.
|
||||
2. Click on the **Applications** button.
|
||||
3. Create a new OAuth2 application under **Manage OAuth2 Applications**.
|
||||
4. Copy **OAuth Redirect URL** from Automatisch to **Redirect URIs. Please use a new line for every URI.** field.
|
||||
5. Copy **Client ID** to **Client ID** field on Automatisch.
|
||||
6. Copy **Client Secret** to **Client Secret** field on Automatisch.
|
||||
7. Add your instance url in the **Instance URL** field on Automatisch.
|
||||
8. Click **Submit** button on Automatisch.
|
||||
9. Congrats! Start using your new Gitea connection within the flows.
|
16
packages/docs/pages/apps/gitea/triggers.md
Normal file
16
packages/docs/pages/apps/gitea/triggers.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
favicon: /favicons/gitea.svg
|
||||
items:
|
||||
- name: New issues
|
||||
desc: Triggers when a new issue is created.
|
||||
- name: New stargazers
|
||||
desc: Triggers when a user stars a repository.
|
||||
- name: New watchers
|
||||
desc: Triggers when a user watches a repository.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
@@ -12,6 +12,7 @@ The following integrations are currently supported by Automatisch.
|
||||
- [Flickr](/apps/flickr/triggers)
|
||||
- [Formatter](/apps/formatter/actions)
|
||||
- [Ghost](/apps/ghost/triggers)
|
||||
- [Gitea](/apps/gitea/triggers)
|
||||
- [GitHub](/apps/github/triggers)
|
||||
- [GitLab](/apps/gitlab/triggers)
|
||||
- [Google Calendar](/apps/google-calendar/triggers)
|
||||
|
1
packages/docs/pages/public/favicons/gitea.svg
Normal file
1
packages/docs/pages/public/favicons/gitea.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" style="enable-background:new 0 0 640 640" xml:space="preserve" width="32" height="32"><path style="fill:#fff" d="m395.9 484.2-126.9-61c-12.5-6-17.9-21.2-11.8-33.8l61-126.9c6-12.5 21.2-17.9 33.8-11.8 17.2 8.3 27.1 13 27.1 13l-.1-109.2 16.7-.1.1 117.1s57.4 24.2 83.1 40.1c3.7 2.3 10.2 6.8 12.9 14.4 2.1 6.1 2 13.1-1 19.3l-61 126.9c-6.2 12.7-21.4 18.1-33.9 12z"/><path style="fill:#609926" d="M622.7 149.8c-4.1-4.1-9.6-4-9.6-4s-117.2 6.6-177.9 8c-13.3.3-26.5.6-39.6.7v117.2c-5.5-2.6-11.1-5.3-16.6-7.9 0-36.4-.1-109.2-.1-109.2-29 .4-89.2-2.2-89.2-2.2s-141.4-7.1-156.8-8.5c-9.8-.6-22.5-2.1-39 1.5-8.7 1.8-33.5 7.4-53.8 26.9C-4.9 212.4 6.6 276.2 8 285.8c1.7 11.7 6.9 44.2 31.7 72.5 45.8 56.1 144.4 54.8 144.4 54.8s12.1 28.9 30.6 55.5c25 33.1 50.7 58.9 75.7 62 63 0 188.9-.1 188.9-.1s12 .1 28.3-10.3c14-8.5 26.5-23.4 26.5-23.4S547 483 565 451.5c5.5-9.7 10.1-19.1 14.1-28 0 0 55.2-117.1 55.2-231.1-1.1-34.5-9.6-40.6-11.6-42.6zM125.6 353.9c-25.9-8.5-36.9-18.7-36.9-18.7S69.6 321.8 60 295.4c-16.5-44.2-1.4-71.2-1.4-71.2s8.4-22.5 38.5-30c13.8-3.7 31-3.1 31-3.1s7.1 59.4 15.7 94.2c7.2 29.2 24.8 77.7 24.8 77.7s-26.1-3.1-43-9.1zm300.3 107.6s-6.1 14.5-19.6 15.4c-5.8.4-10.3-1.2-10.3-1.2s-.3-.1-5.3-2.1l-112.9-55s-10.9-5.7-12.8-15.6c-2.2-8.1 2.7-18.1 2.7-18.1L322 273s4.8-9.7 12.2-13c.6-.3 2.3-1 4.5-1.5 8.1-2.1 18 2.8 18 2.8L467.4 315s12.6 5.7 15.3 16.2c1.9 7.4-.5 14-1.8 17.2-6.3 15.4-55 113.1-55 113.1z"/><path style="fill:#609926" d="M326.8 380.1c-8.2.1-15.4 5.8-17.3 13.8-1.9 8 2 16.3 9.1 20 7.7 4 17.5 1.8 22.7-5.4 5.1-7.1 4.3-16.9-1.8-23.1l24-49.1c1.5.1 3.7.2 6.2-.5 4.1-.9 7.1-3.6 7.1-3.6 4.2 1.8 8.6 3.8 13.2 6.1 4.8 2.4 9.3 4.9 13.4 7.3.9.5 1.8 1.1 2.8 1.9 1.6 1.3 3.4 3.1 4.7 5.5 1.9 5.5-1.9 14.9-1.9 14.9-2.3 7.6-18.4 40.6-18.4 40.6-8.1-.2-15.3 5-17.7 12.5-2.6 8.1 1.1 17.3 8.9 21.3 7.8 4 17.4 1.7 22.5-5.3 5-6.8 4.6-16.3-1.1-22.6 1.9-3.7 3.7-7.4 5.6-11.3 5-10.4 13.5-30.4 13.5-30.4.9-1.7 5.7-10.3 2.7-21.3-2.5-11.4-12.6-16.7-12.6-16.7-12.2-7.9-29.2-15.2-29.2-15.2s0-4.1-1.1-7.1c-1.1-3.1-2.8-5.1-3.9-6.3 4.7-9.7 9.4-19.3 14.1-29-4.1-2-8.1-4-12.2-6.1-4.8 9.8-9.7 19.7-14.5 29.5-6.7-.1-12.9 3.5-16.1 9.4-3.4 6.3-2.7 14.1 1.9 19.8l-24.6 50.4z"/></svg>
|
After Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user