Skip to content

Commit

Permalink
👽 Update GitHub Actions output due to set-output deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Oct 12, 2022
1 parent d9b3c4a commit f21a18e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/actions/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package dump

import (
"errors"
"fmt"
"github.com/clevyr/kubedb/internal/command"
"github.com/clevyr/kubedb/internal/config"
"github.com/clevyr/kubedb/internal/database/sqlformat"
"github.com/clevyr/kubedb/internal/github"
"github.com/clevyr/kubedb/internal/progressbar"
gzip "github.com/klauspost/pgzip"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -62,7 +62,9 @@ func (action Dump) Run() (err error) {
}).Info("exporting database")

if viper.GetBool("github-actions") {
fmt.Println("::set-output name=filename::" + action.Filename)
if err := github.SetOutput("filename", action.Filename); err != nil {
return err
}
}

var startTime = time.Now()
Expand Down
22 changes: 22 additions & 0 deletions internal/github/actions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package github

import (
"fmt"
"os"
)

func SetOutput(name, value string) error {
if filename := os.Getenv("GITHUB_OUTPUT"); filename != "" {
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0755)
if err != nil {
return err
}
if _, err := f.WriteString(name + "=" + value + "\n"); err != nil {
return err
}
return f.Close()
} else {
fmt.Println("::set-output name=" + name + "::" + value)
}
return nil
}

0 comments on commit f21a18e

Please sign in to comment.