流水线节点管理和模板管理

This commit is contained in:
2024-05-07 14:08:46 +08:00
parent 5a61933857
commit 8ae91ff558
48 changed files with 1348 additions and 9 deletions

71
app/models/action/node.rb Normal file
View File

@@ -0,0 +1,71 @@
# == Schema Information
#
# Table name: action_nodes
#
# id :integer not null, primary key
# name :string(255)
# full_name :string(255)
# description :string(255)
# icon :string(255)
# action_node_types_id :integer
# is_local :boolean default("0")
# local_url :string(255)
# yaml :text(65535)
# sort_no :integer default("0")
# use_count :integer default("0")
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_action_nodes_on_action_types_id (action_node_types_id)
# index_action_nodes_on_user_id (user_id)
#
class Action::Node < ApplicationRecord
self.table_name = 'action_nodes'
default_scope { order(sort_no: :asc) }
has_many :action_node_inputs, :class_name => 'Action::NodeInput', foreign_key: "action_nodes_id"
has_many :action_node_selects, :class_name => 'Action::NodeSelect', foreign_key: "action_nodes_id"
belongs_to :action_node_type, :class_name => 'Action::NodeType', foreign_key: "action_node_types_id"
belongs_to :user, optional: true
# def content_yaml
# "foo".to_yaml
# <<~YAML
# - name: Set up JDK ${{ matrix.java }}
# uses: actions/setup-java@v3
# with:
# distribution: 'temurin'
# java-version: ${{ matrix.java }}
# YAML
# end
def yaml_hash
<<~YAML
name: Check dist
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
jobs:
call-check-dist:
name: Check dist/
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
with:
node-version: '20.x'
YAML
end
end

View File

@@ -0,0 +1,27 @@
# == Schema Information
#
# Table name: action_node_inputs
#
# id :integer not null, primary key
# action_nodes_id :integer
# name :string(255)
# input_type :string(255)
# description :string(255)
# is_required :boolean default("0")
# sort_no :string(255) default("0")
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_action_node_inputs_on_action_nodes_id (action_nodes_id)
# index_action_node_inputs_on_user_id (user_id)
#
class Action::NodeInput < ApplicationRecord
self.table_name = 'action_node_inputs'
default_scope { order(sort_no: :asc) }
belongs_to :action_node, :class_name => 'Action::Node', foreign_key: "action_nodes_id"
end

View File

@@ -0,0 +1,39 @@
# == Schema Information
#
# Table name: action_node_selects
#
# id :integer not null, primary key
# action_nodes_id :integer
# name :string(255)
# val :string(255)
# val_ext :string(255)
# description :string(255)
# download_url :string(255)
# sort_no :integer default("0")
# use_count :integer default("0")
# user_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_action_node_selects_on_action_nodes_id (action_nodes_id)
# index_action_node_selects_on_name (name)
# index_action_node_selects_on_user_id (user_id)
#
class Action::NodeSelect < ApplicationRecord
self.table_name = 'action_node_selects'
default_scope { order(sort_no: :asc) }
belongs_to :action_node, :class_name => 'Action::Node', foreign_key: "action_nodes_id"
belongs_to :user, optional: true
def value
if self.val_ext.blank?
self.val
else
"#{self.val}@#{self.val_ext}"
end
end
end

View File

@@ -0,0 +1,18 @@
# == Schema Information
#
# Table name: action_node_types
#
# id :integer not null, primary key
# name :string(255)
# description :string(255)
# sort_no :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Action::NodeType < ApplicationRecord
self.table_name = 'action_node_types'
default_scope { order(sort_no: :asc) }
has_many :action_nodes, :class_name => 'Action::Node', foreign_key: "action_node_types_id"
end

View File

@@ -0,0 +1,20 @@
# == Schema Information
#
# Table name: action_templates
#
# id :integer not null, primary key
# name :string(255)
# description :string(255)
# img :string(255)
# sort_no :string(255) default("0")
# json :text(65535)
# yaml :text(65535)
# created_at :datetime not null
# updated_at :datetime not null
#
class Action::Template < ApplicationRecord
self.table_name = 'action_templates'
default_scope { order(sort_no: :asc) }
end