Skip to content

Commit

Permalink
chore: support ignoring artifact upload failures
Browse files Browse the repository at this point in the history
Support ignoring artifact upload failures with GitHub actions.

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
frezbo committed Nov 20, 2023
1 parent 56121e8 commit 0759c81
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
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

0 comments on commit 0759c81

Please sign in to comment.