forked from nicolas-fricke/bitrise-step-generate-text-file
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
33 lines (26 loc) · 779 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"fmt"
"log"
"os"
"os/exec"
"github.com/bitrise-io/go-utils/pathutil"
"github.com/bitrise-io/go-utils/fileutil"
)
func main() {
fileName := os.Getenv("file_name")
absFilePath, err := pathutil.AbsPath(fileName)
if err != nil {
log.Fatalf("Failed to determine absolute path of file (%s): %+v", fileName, err)
}
if err := fileutil.WriteStringToFile(absFilePath, os.Getenv("file_content")); err != nil {
log.Fatalf("Failed to write into file: %+v", err)
}
// Output
cmdLog, err := exec.Command("bitrise", "envman", "add", "--key", "GENERATED_TEXT_FILE_PATH", "--value", absFilePath).CombinedOutput()
if err != nil {
fmt.Printf("Failed to expose output with envman, error: %#v | output: %s", err, cmdLog)
os.Exit(1)
}
os.Exit(0)
}