1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

refactor: re-implement embed without "unused" import (#830)

* refactor: re-implement `embed` without "unused" import

* fix(gitignore): ignore local docker registry data
This commit is contained in:
Ryan 2021-09-27 17:33:14 +00:00 committed by GitHub
parent 26ae039f33
commit df05a7364e

View file

@ -3,11 +3,9 @@ package runner
import (
"archive/tar"
"context"
"io"
// Go told me to?
_ "embed"
"embed"
"fmt"
"io"
"io/ioutil"
"os"
"path"
@ -335,7 +333,7 @@ func (sc *StepContext) runUsesContainer() common.Executor {
}
//go:embed res/trampoline.js
var trampoline []byte
var trampoline embed.FS
func (sc *StepContext) setupAction(actionDir string, actionPath string, localAction bool) common.Executor {
return func(ctx context.Context) error {
@ -378,7 +376,11 @@ func (sc *StepContext) setupAction(actionDir string, actionPath string, localAct
}
if sc.Step.With != nil {
if val, ok := sc.Step.With["args"]; ok {
err2 := ioutil.WriteFile(filepath.Join(actionDir, actionPath, "trampoline.js"), trampoline, 0400)
var b []byte
if b, err = trampoline.ReadFile("res/trampoline.js"); err != nil {
return err
}
err2 := ioutil.WriteFile(filepath.Join(actionDir, actionPath, "trampoline.js"), b, 0400)
if err2 != nil {
return err
}