Skip to content

Commit

Permalink
Don't use Tempdir with system default
Browse files Browse the repository at this point in the history
Github Actions doesn't have a `/tmp` directory so this PR switches from using Tempdir to using the present directory for output of the body & name. It then supplies a directory to Tempdir so that it puts the tempfiles into `$RUNNER_TEMP` for extracting TAR files.

Signed-off-by: Daniel Mikusa <dmikusa@vmware.com>
  • Loading branch information
Daniel Mikusa committed Apr 14, 2022
1 parent 668c8d9 commit 98df89f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions actions/draft-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,8 @@ func main() {
panic(err)
}

scratchDir, err := ioutil.TempDir("", "drafts")
if err != nil {
panic(err)
}

err = drafter.BuildAndWriteReleaseToFileDraftFromTemplate(
filepath.Join(scratchDir, "body"), templateContents, payload)
filepath.Join(".", "body"), templateContents, payload)
if err != nil {
panic(err)
}
Expand All @@ -56,7 +51,7 @@ func main() {
name = fmt.Sprintf("%s %s", payload.PrimaryBuildpack.Info.Name, payload.Release.Name)
}

err = ioutil.WriteFile(filepath.Join(scratchDir, "name"), []byte(name), 0644)
err = ioutil.WriteFile(filepath.Join(".", "name"), []byte(name), 0644)
if err != nil {
panic(err)
}
Expand All @@ -68,12 +63,12 @@ func main() {
"--method", "PATCH",
fmt.Sprintf("/repos/:owner/:repo/releases/%s", payload.Release.ID),
"--field", fmt.Sprintf("tag_name=%s", payload.Release.Tag),
"--field", fmt.Sprintf("name=@%s/name", scratchDir),
"--field", fmt.Sprintf("body=@%s/body", scratchDir),
"--field", "name=@./name",
"--field", "body=@./body",
},
}
if _, dryRun := inputs["dry_run"]; dryRun {
bits, err := ioutil.ReadFile(filepath.Join(scratchDir, "body"))
bits, err := ioutil.ReadFile(filepath.Join(".", "body"))
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion drafts/drafts.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (r RegistryBuildpackLoader) LoadBuildpacks(uris []string) ([]Buildpack, err
}

func (r RegistryBuildpackLoader) LoadBuildpack(uri string) (Buildpack, error) {
tarFile, err := ioutil.TempFile("", "tarfiles")
tarFile, err := ioutil.TempFile(os.Getenv("RUNNER_TEMP"), "tarfiles")
if err != nil {
return Buildpack{}, fmt.Errorf("unable to create tempfile\n%w", err)
}
Expand Down

0 comments on commit 98df89f

Please sign in to comment.