Compare commits

...

1 Commits

Author SHA1 Message Date
Rıdvan Akca
93fdc05529 feat(gitea): add create issue action 2024-05-13 16:52:13 +02:00
6 changed files with 123 additions and 1 deletions

View 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 });
},
});

View File

@@ -0,0 +1,3 @@
import createIssue from './create-issue/index.js';
export default [createIssue];

View File

@@ -8,6 +8,7 @@ export default {
};
const repoOwner = $.auth.data.repoOwner;
const repo = $.step.parameters.repo;
const showLabelId = $.step.parameters.showLabelId === 'true';
const params = {
page: 1,
@@ -27,8 +28,9 @@ export default {
if (data?.length) {
for (const label of data) {
const value = showLabelId ? label.id : label.name;
labels.data.push({
value: label.name,
value,
name: label.name,
});
}

View File

@@ -4,6 +4,7 @@ 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',
@@ -18,4 +19,5 @@ export default defineApp({
auth,
triggers,
dynamicData,
actions,
});

View File

@@ -128,6 +128,7 @@ export default defineConfig({
collapsed: true,
items: [
{ text: 'Triggers', link: '/apps/gitea/triggers' },
{ text: 'Actions', link: '/apps/gitea/actions' },
{ text: 'Connection', link: '/apps/gitea/connection' },
],
},

View 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 />