Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/pkg/executor/z_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func ToActionSpec(action *actions.Action, repo *repository.Repository) (ActionSp
return spec, nil
}

func inputToken(m map[string]workflows.Input) workflows.Token {
func inputToken(m map[string]actions.Input) workflows.Token {
tokens := make([][2]workflows.Token, 0)
for name, input := range m {
if input.Default != nil {
Expand All @@ -173,7 +173,7 @@ func inputToken(m map[string]workflows.Input) workflows.Token {
return nil
}

func outputToken(m map[string]workflows.Output) workflows.Token {
func outputToken(m map[string]actions.Output) workflows.Token {
tokens := make([][2]workflows.Token, 0)
for name, output := range m {
if output.Value != nil {
Expand Down
20 changes: 9 additions & 11 deletions core/pkg/model/actions/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,37 @@

package actions

import "drassi.run/core/pkg/model/workflows"

type Action struct {
// The name of your action. GitHub displays the `name` in the Actions tab to help visually identify actions in each job.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#name
Name string `json:"name,omitempty" yaml:"name,omitempty" actions:"name,omitempty" validate:"required"`
Name string `json:"name,omitempty"`

// The name of the action's author.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#author
Author string `json:"author,omitempty" yaml:"author,omitempty" actions:"author,omitempty"`
Author string `json:"author,omitempty"`

// A short description of the action.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#description
Description string `json:"description,omitempty" yaml:"description,omitempty" actions:"description,omitempty" validate:"required"`
Description string `json:"description,omitempty"`

// Input parameters allow you to specify data that the action expects to use during runtime.
// GitHub stores input parameters as environment variables.
// Input ids with uppercase letters are converted to lowercase during runtime. We recommended using lowercase input ids.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
Inputs map[string]workflows.Input `json:"inputs,omitempty" yaml:"inputs,omitempty" actions:"inputs,omitempty"`
Inputs map[string]Input `json:"inputs,omitempty"`

// Output parameters allow you to declare data that an action sets.
// Actions that run later in a workflow can use the output data set in previously run actions.
Outputs map[string]workflows.Output `json:"outputs,omitempty" yaml:"outputs,omitempty" actions:"outputs,omitempty"`
Outputs map[string]Output `json:"outputs,omitempty"`

// Specifies whether this is a JavaScript action, a composite action, or a Docker container action and how the action is executed.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs
Runs Runs `json:"runs,omitempty" yaml:"runs,omitempty" actions:"runs,omitempty" validate:"required"`
Runs Runs `json:"runs,omitempty"`

// You can use a color and Feather icon to create a badge to personalize and distinguish your action.
// Badges are shown next to your action name in GitHub Marketplace.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#branding
Branding Branding `json:"branding,omitempty" yaml:"branding,omitempty" actions:"branding,omitempty"`
Branding Branding `json:"branding,omitempty"`
}

// You can use a color and Feather icon to create a badge to personalize and distinguish your action.
Expand All @@ -47,9 +45,9 @@ type Action struct {
type Branding struct {
// The background color of the badge.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#brandingcolor
Color string `json:"color,omitempty" yaml:"color,omitempty" actions:"color,omitempty"`
Color string `json:"color,omitempty"`

// The name of the Feather icon to use.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#brandingicon
Icon string `json:"icon,omitempty" yaml:"icon,omitempty" actions:"icon,omitempty"`
Icon string `json:"icon,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

package workflows
package actions

import "drassi.run/core/pkg/model/workflows"

// A string identifier to associate with the input. The value of <input_id> is a map of the input's metadata.
// The <input_id> must be a unique identifier within the inputs object.
Expand All @@ -13,30 +15,30 @@ package workflows
type Input struct {
// Required A string description of the input parameter.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputsinput_iddescription
Description string `json:"description,omitempty" yaml:"description,omitempty" actions:"description,omitempty"`
Description string `json:"description,omitempty"`

// A string shown to users using the deprecated input.
DeprecationMessage string `json:"deprecationMessage,omitempty" yaml:"deprecationMessage,omitempty" actions:"deprecationMessage,omitempty"`
DeprecationMessage string `json:"deprecationMessage,omitempty"`

// A boolean to indicate whether the action requires the input parameter. Set to true when the parameter is required.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputsinput_idrequired
Required bool `json:"required,omitempty" yaml:"required,omitempty" actions:"required,omitempty"`
Required bool `json:"required,omitempty"`

// A string representing the default value. The default value is used when an input parameter isn't specified in a workflow file.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputsinput_iddefault
//
// Context available: `github`, `inputs`, `vars`
// https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
Default Evaluable[any] `json:"default,omitempty" yaml:"default,omitempty" actions:"default,omitempty"` // TODO type args
Default workflows.Evaluable[any] `json:"default,omitempty"` // TODO type args

// The value of this parameter is a string specifying the data type of the input.
// This must be one of: boolean, choice, number, environment or string.
// https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatchinputsinput_idtype
Type InputType `json:"type,omitempty" yaml:"type,omitempty" actions:"type,omitempty"`
Type InputType `json:"type,omitempty"`

// The options of the dropdown list, if the type is a choice.
// https://github.blog/changelog/2021-11-10-github-actions-input-types-for-manual-workflows/
Options []string `json:"options,omitempty" yaml:"options,omitempty" actions:"options,omitempty"`
Options []string `json:"options,omitempty"`
}

type InputType string
Expand All @@ -50,20 +52,20 @@ const (
)

type Output struct {
Description string `json:"description,omitempty" yaml:"description,omitempty" actions:"description,omitempty"`
Description string `json:"description,omitempty"`

// Context available: `github`, `jobs`, `vars`, `inputs`
// https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
Value Evaluable[string] `json:"value,omitempty" yaml:"value,omitempty" actions:"value,omitempty"`
Value workflows.Evaluable[string] `json:"value,omitempty"`
}

// A string identifier to associate with the secret.
// https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callsecretssecret_id
type Secret struct {
// Required A string description of the secret parameter.
Description string `json:"description,omitempty" yaml:"description,omitempty" actions:"description,omitempty"`
Description string `json:"description,omitempty"`

// A boolean specifying whether the secret must be supplied.
// https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callsecretssecret_idrequired
Required bool `json:"required,omitempty" yaml:"required,omitempty" actions:"required,omitempty"`
Required bool `json:"required,omitempty"`
}
34 changes: 17 additions & 17 deletions core/pkg/model/actions/runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@ type Runs interface {
type NodeRuns struct {
// The application used to execute the code specified in `main`.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsusing-for-javascript-actions
Using string `json:"using,omitempty" yaml:"using,omitempty" actions:"using,omitempty" validate:"required"`
Using string `json:"using,omitempty"`

// The file that contains your action code. The application specified in `using` executes this file.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsmain
Main string `json:"main,omitempty" yaml:"main,omitempty" actions:"main,omitempty" validate:"required"`
Main string `json:"main,omitempty"`

// Allows you to run a script at the start of a job, before the `main:` action begins.
// For example, you can use `pre:` to run a prerequisite setup script. The application specified with
// the `using` syntax will execute this file.
// The `pre:` action always runs by default but you can override this using `pre-if`.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runspre
Pre string `json:"pre,omitempty" yaml:"pre,omitempty" actions:"pre,omitempty"`
Pre string `json:"pre,omitempty"`

// Allows you to define conditions for the pre: action execution.
// The pre: action will only run if the conditions in pre-if are met.
// If not set, then pre-if defaults to always().
// In pre-if, status check functions evaluate against the job's status, not the action's own status.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runspre-if
PreIf workflows.Conditional `json:"pre-if,omitempty" yaml:"pre-if,omitempty" actions:"pre-if,omitempty"`
PreIf workflows.Conditional `json:"pre-if,omitempty"`

// Allows you to run a script at the end of a job, once the main: action has completed.
// For example, you can use post: to terminate certain processes or remove unneeded files.
// The runtime specified with the using syntax will execute this file.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runspost
Post string `json:"post,omitempty" yaml:"post,omitempty" actions:"post,omitempty"`
Post string `json:"post,omitempty"`

// Allows you to define conditions for the post: action execution.
// The post: action will only run if the conditions in post-if are met.
// If not set, then post-if defaults to always().
// In post-if, status check functions evaluate against the job's status, not the action's own status.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runspost-if
PostIf workflows.Conditional `json:"post-if,omitempty" yaml:"post-if,omitempty" actions:"post-if,omitempty"`
PostIf workflows.Conditional `json:"post-if,omitempty"`
}

func (r *NodeRuns) isRuns() {
Expand All @@ -55,30 +55,30 @@ func (r *NodeRuns) isRuns() {
type DockerRuns struct {
// You must set this value to 'docker'.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsusing-for-docker-container-actions
Using string `json:"using,omitempty" yaml:"using,omitempty" actions:"using,omitempty" validate:"required"`
Using string `json:"using,omitempty"`

// The Docker image to use as the container to run the action. The value can be the Docker base image name,
// a local `Dockerfile` in your repository, or a public image in Docker Hub or another registry.
// To reference a `Dockerfile` local to your repository, use a path relative to your action metadata file.
// The `docker` application will execute this file.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsimage
Image string `json:"image,omitempty" yaml:"image,omitempty" actions:"image,omitempty" validate:"required"`
Image string `json:"image,omitempty"`

// Specifies a key/value map of environment variables to set in the container environment.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsenv
//
// To set custom environment variables, you need to specify the variables in the workflow file.
// You can define environment variables for a step, job, or entire workflow using the jobs.<job_id>.steps[*].env, jobs.<job_id>.env, and env keywords.
// For more information, see https://docs.github.com/en/actions/learn-github-actions/variables
Env workflows.Evaluable[map[string]string] `json:"env,omitempty" yaml:"env,omitempty" actions:"env,omitempty"`
Env workflows.Evaluable[map[string]string] `json:"env,omitempty"`

// Overrides the Docker `ENTRYPOINT` in the `Dockerfile`, or sets it if one wasn't already specified.
// Use `entrypoint` when the `Dockerfile` does not specify an `ENTRYPOINT` or you want to override the `ENTRYPOINT` instruction.
// If you omit `entrypoint`, the commands you specify in the Docker `ENTRYPOINT` instruction will execute.
// The Docker `ENTRYPOINT instruction has a *shell* form and *exec* form. The Docker `ENTRYPOINT` documentation
// recommends using the *exec* form of the `ENTRYPOINT` instruction.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsentrypoint
Entrypoint string `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty" actions:"entrypoint,omitempty"`
Entrypoint string `json:"entrypoint,omitempty"`

// An array of strings that define the inputs for a Docker container. Inputs can include hardcoded strings.
// GitHub passes the `args` to the container's `ENTRYPOINT` when the container starts up.
Expand All @@ -88,24 +88,24 @@ type DockerRuns struct {
// - Use defaults that allow using the action without specifying any `args`.
// - If the action exposes a `--help` flag, or something similar, use that to make your action self-documenting.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsargs
Args workflows.Evaluable[[]string] `json:"args,omitempty" yaml:"args,omitempty" actions:"args,omitempty"`
Args workflows.Evaluable[[]string] `json:"args,omitempty"`

// Allows you to run a script before the `entrypoint` action begins. For example, you can use `pre-entrypoint:` to run a prerequisite setup script.
// GitHub Actions uses `docker run` to launch this action, and runs the script inside a new container that uses the same base image.
// This means that the runtime state is different from the main `entrypoint` container, and any states you require must be accessed
// in either the workspace, `HOME`, or as a `STATE_` variable.
// The `pre-entrypoint:` action always runs by default but you can override this using `pre-if`.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runspre-entrypoint
PreEntrypoint string `json:"pre-entrypoint,omitempty" yaml:"pre-entrypoint,omitempty" actions:"pre-entrypoint,omitempty"`
PreIf workflows.Conditional `json:"pre-if,omitempty" yaml:"pre-if,omitempty" actions:"pre-if,omitempty"`
PreEntrypoint string `json:"pre-entrypoint,omitempty"`
PreIf workflows.Conditional `json:"pre-if,omitempty"`

// Allows you to run a cleanup script once the `runs.entrypoint` action has completed. GitHub Actions uses `docker run` to launch this action.
// Because GitHub Actions runs the script inside a new container using the same base image, the runtime state is different from the main `entrypoint` container.
// You can access any state you need in either the workspace, `HOME`, or as a `STATE_` variable.
// The `post-entrypoint:` action always runs by default but you can override this using `post-if`.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runspost-entrypoint
PostEntrypoint string `json:"post-entrypoint,omitempty" yaml:"post-entrypoint,omitempty" actions:"post-entrypoint,omitempty"`
PostIf workflows.Conditional `json:"post-if,omitempty" yaml:"post-if,omitempty" actions:"post-if,omitempty"`
PostEntrypoint string `json:"post-entrypoint,omitempty"`
PostIf workflows.Conditional `json:"post-if,omitempty"`
}

func (r *DockerRuns) isRuns() {
Expand All @@ -114,11 +114,11 @@ func (r *DockerRuns) isRuns() {
type CompositeRuns struct {
// To use a composite run steps action, set this to 'composite'.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-actions
Using string `json:"using,omitempty" yaml:"using,omitempty" actions:"using,omitempty" validate:"required"`
Using string `json:"using,omitempty"`

// The steps that you plan to run in this action. These can be either run steps or uses steps.
// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runssteps
Steps []workflows.Step `json:"steps,omitempty" yaml:"steps,omitempty" actions:"steps,omitempty" validate:"required"`
Steps []workflows.Step `json:"steps,omitempty"`
}

func (r *CompositeRuns) isRuns() {
Expand Down
60 changes: 0 additions & 60 deletions core/pkg/model/actions/runs_serde.go

This file was deleted.

Loading
Loading