Skip to content

Commit

Permalink
Fix linux amd64 act script (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham149 committed May 3, 2023
1 parent dcf4168 commit 05adaad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
8 changes: 7 additions & 1 deletion plugin/github/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/drone/plugin/plugin/internal/encoder"
Expand Down Expand Up @@ -92,10 +93,15 @@ func diffEnv(before, after string) map[string]string {
}
}

encoding := base64.StdEncoding
if runtime.GOOS == "windows" {
encoding = base64.RawURLEncoding
}

// Base64 decode env values
diff := make(map[string]string)
for k, v := range diffB64 {
data, err := base64.RawURLEncoding.DecodeString(v)
data, err := encoding.DecodeString(v)
if err == nil {
diff[k] = string(data)
} else {
Expand Down
19 changes: 9 additions & 10 deletions plugin/github/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,18 @@ func getWorkflowEvent() string {
}

func prePostStep(name, envFile string) step {
log := slog.Default()

script, err := dotenvScript(envFile)
if err != nil {
log.Warn(fmt.Sprintf("failed to create pre/post-step script: %s", err))
script = "--version"
}

var cmd string
if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
cmd = fmt.Sprintf("python3 %s", script)
} else {
cmd = fmt.Sprintf("python3 -c 'import os; import base64; [print(k+\"=\"+str(base64.b64encode(bytes(v, \"utf-8\")), \"utf-8\")) for k, v in os.environ.items()]' > %s", envFile)
} else if runtime.GOOS == "windows" {
script, err := dotenvScript(envFile)
if err != nil {
slog.Default().Warn(fmt.Sprintf("failed to create pre/post-step script: %s", err))
script = "--version"
}
cmd = fmt.Sprintf("python %s", script)
} else {
cmd = fmt.Sprintf("python -c 'import os; import base64; [print(k+\"=\"+str(base64.b64encode(bytes(v, \"utf-8\")), \"utf-8\")) for k, v in os.environ.items()]' > %s", envFile)
}
s := step{
Name: name,
Expand Down

0 comments on commit 05adaad

Please sign in to comment.