Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: support ignoring artifact upload failures #328

Merged
Merged
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
15 changes: 8 additions & 7 deletions internal/output/ghworkflow/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ type Service struct {

// Step represents GitHub Actions step.
type Step struct {
Name string `yaml:"name"`
ID string `yaml:"id,omitempty"`
If string `yaml:"if,omitempty"`
Uses string `yaml:"uses,omitempty"`
With map[string]string `yaml:"with,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Run string `yaml:"run,omitempty"`
Name string `yaml:"name"`
ID string `yaml:"id,omitempty"`
If string `yaml:"if,omitempty"`
Uses string `yaml:"uses,omitempty"`
With map[string]string `yaml:"with,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Run string `yaml:"run,omitempty"`
ContinueOnError bool `yaml:"continue-on-error,omitempty"`
}
25 changes: 15 additions & 10 deletions internal/project/custom/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ type Step struct {
Artifacts struct {
ExtraPaths []string `yaml:"extraPaths"`
Additional []struct {
Name string `yaml:"name"`
Paths []string `yaml:"paths"`
Always bool `yaml:"always"`
Name string `yaml:"name"`
Paths []string `yaml:"paths"`
Always bool `yaml:"always"`
ContinueOnError bool `yaml:"continueOnError"`
} `yaml:"additional"`
Enabled bool `yaml:"enabled"`
Enabled bool `yaml:"enabled"`
ContinueOnError bool `yaml:"continueOnError"`
} `yaml:"artifacts"`
Enabled bool `yaml:"enabled"`
} `yaml:"ghaction"`
Expand Down Expand Up @@ -315,8 +317,9 @@ func (step *Step) CompileGitHubWorkflow(output *ghworkflow.Output) error {
Run: fmt.Sprintf("find %s -type f -executable > %s/executable-artifacts", step.meta.ArtifactsPath, step.meta.ArtifactsPath) + "\n",
},
&ghworkflow.Step{
Name: "save-artifacts",
Uses: fmt.Sprintf("actions/upload-artifact@%s", config.UploadArtifactActionVersion),
Name: "save-artifacts",
Uses: fmt.Sprintf("actions/upload-artifact@%s", config.UploadArtifactActionVersion),
ContinueOnError: step.GHAction.Artifacts.ContinueOnError,
With: map[string]string{
"name": "artifacts",
"path": step.meta.ArtifactsPath + "\n" + strings.Join(step.GHAction.Artifacts.ExtraPaths, "\n"),
Expand All @@ -327,8 +330,9 @@ func (step *Step) CompileGitHubWorkflow(output *ghworkflow.Output) error {

for _, additionalArtifact := range step.GHAction.Artifacts.Additional {
artifactStep := &ghworkflow.Step{
Name: fmt.Sprintf("save-%s-artifacts", additionalArtifact.Name),
Uses: fmt.Sprintf("actions/upload-artifact@%s", config.UploadArtifactActionVersion),
Name: fmt.Sprintf("save-%s-artifacts", additionalArtifact.Name),
Uses: fmt.Sprintf("actions/upload-artifact@%s", config.UploadArtifactActionVersion),
ContinueOnError: step.GHAction.Artifacts.ContinueOnError,
With: map[string]string{
"name": additionalArtifact.Name,
"path": strings.Join(additionalArtifact.Paths, "\n"),
Expand Down Expand Up @@ -365,8 +369,9 @@ func (step *Step) CompileGitHubWorkflow(output *ghworkflow.Output) error {
if step.GHAction.Artifacts.Enabled {
for _, additionalArtifact := range step.GHAction.Artifacts.Additional {
artifactStep := &ghworkflow.Step{
Name: fmt.Sprintf("save-%s-artifacts", additionalArtifact.Name),
Uses: fmt.Sprintf("actions/upload-artifact@%s", config.UploadArtifactActionVersion),
Name: fmt.Sprintf("save-%s-artifacts", additionalArtifact.Name),
Uses: fmt.Sprintf("actions/upload-artifact@%s", config.UploadArtifactActionVersion),
ContinueOnError: additionalArtifact.ContinueOnError,
With: map[string]string{
"name": fmt.Sprintf("%s-%s", additionalArtifact.Name, job.Name),
"path": strings.Join(additionalArtifact.Paths, "\n"),
Expand Down