Skip to content

Commit ad9c4bd

Browse files
committed
remove INPUT_DIR
1 parent 38f1155 commit ad9c4bd

File tree

5 files changed

+11
-24
lines changed

5 files changed

+11
-24
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
example:
22
go build -mod vendor
3-
INPUT_DIR=example \
3+
(cd example && \
44
INPUT_GOOGLE_APPLICATION_CREDENTIALS=.google_application_credentials.json \
55
GITHUB_RUN_NUMBER=126 \
66
GITHUB_SHA=13e82dd30df4e87118faa98712a5aebb0ab05c45 \
7-
./gce-deploy-action
7+
../gce-deploy-action)
88

99
github-action:
1010
docker build -t mattes/gce-deploy-action .

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ deploys:
8585
8686
| Variable | Description |
8787
|----------------------------------|-----------------------------------------------------------------------------|
88-
| `dir` | Working directory. Defaults to root directory of repository. |
8988
| `config` | Path to config file. Default `deploy.yml` or `deploy.yaml`. |
9089
| `google_application_credentials` | Either a path or the contents of a Service Account JSON Key. |
9190

config.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
var environ = os.Environ()
1818

1919
type GithubActionConfig struct {
20-
Dir string
2120
Config string
2221
GoogleApplicationCredentials string
2322
googleApplicationCredentialsData string
@@ -26,25 +25,14 @@ type GithubActionConfig struct {
2625
func ReadGithubActionConfig() (*GithubActionConfig, error) {
2726
c := &GithubActionConfig{}
2827

29-
c.Dir = os.Getenv("INPUT_DIR")
30-
if c.Dir == "" {
31-
wd, err := os.Getwd()
32-
if err != nil {
33-
return nil, err
34-
}
35-
c.Dir = wd
36-
}
37-
3828
c.Config = os.Getenv("INPUT_CONFIG")
3929
if c.Config == "" {
40-
c.Config = filepath.Join(c.Dir, "deploy.yml")
41-
} else {
42-
c.Config = filepath.Join(c.Dir, c.Config)
30+
c.Config = "deploy.yml"
4331
}
4432

4533
// read Google Application Credentials if this is a path
4634
c.GoogleApplicationCredentials = os.Getenv("INPUT_GOOGLE_APPLICATION_CREDENTIALS")
47-
f, err := ioutil.ReadFile(filepath.Join(c.Dir, c.GoogleApplicationCredentials))
35+
f, err := ioutil.ReadFile(c.GoogleApplicationCredentials)
4836
if err == nil {
4937
c.googleApplicationCredentialsData = string(f)
5038
} else {
@@ -100,7 +88,7 @@ type Deploy struct {
10088
Tags []string `yaml:"tags"`
10189
}
10290

103-
func ParseConfig(workingDir string, b io.Reader) (*Config, error) {
91+
func ParseConfig(b io.Reader) (*Config, error) {
10492
c := &Config{}
10593
d := yaml.NewDecoder(b)
10694
d.SetStrict(true)
@@ -125,7 +113,7 @@ func ParseConfig(workingDir string, b io.Reader) (*Config, error) {
125113

126114
dy.GoogleApplicationCredentials = expandShellRe(dy.GoogleApplicationCredentials, getEnv(nil))
127115

128-
f, err := ioutil.ReadFile(filepath.Join(workingDir, dy.GoogleApplicationCredentials))
116+
f, err := ioutil.ReadFile(dy.GoogleApplicationCredentials)
129117
if err == nil {
130118
dy.googleApplicationCredentialsData = string(f)
131119
} else {
@@ -180,23 +168,23 @@ func ParseConfig(workingDir string, b io.Reader) (*Config, error) {
180168
dy := &c.Deploys[i]
181169

182170
if dy.StartupScriptPath != "" {
183-
f, err := ioutil.ReadFile(filepath.Join(workingDir, dy.StartupScriptPath))
171+
f, err := ioutil.ReadFile(dy.StartupScriptPath)
184172
if err != nil {
185173
return nil, fmt.Errorf("startup_script: %v", err)
186174
}
187175
dy.startupScript = expandMakeRe(string(f), getEnv(dy.Vars))
188176
}
189177

190178
if dy.ShutdownScriptPath != "" {
191-
f, err := ioutil.ReadFile(filepath.Join(workingDir, dy.ShutdownScriptPath))
179+
f, err := ioutil.ReadFile(dy.ShutdownScriptPath)
192180
if err != nil {
193181
return nil, fmt.Errorf("shutdown_script: %v", err)
194182
}
195183
dy.shutdownScript = expandMakeRe(string(f), getEnv(dy.Vars))
196184
}
197185

198186
if dy.CloudInitPath != "" {
199-
f, err := ioutil.ReadFile(filepath.Join(workingDir, dy.CloudInitPath))
187+
f, err := ioutil.ReadFile(dy.CloudInitPath)
200188
if err != nil {
201189
return nil, fmt.Errorf("cloud_init: %v", err)
202190
}

config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ deploys:
4141
`
4242

4343
environ = append(environ, "BAR=FOO")
44-
c, err := ParseConfig("", strings.NewReader(config))
44+
c, err := ParseConfig(strings.NewReader(config))
4545
require.NoError(t, err)
4646

4747
require.Len(t, c.Deploys, 1)

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func main() {
2323
}
2424
defer f.Close()
2525

26-
c, err := ParseConfig(gc.Dir, f)
26+
c, err := ParseConfig(f)
2727
if err != nil {
2828
Fatalf("%v", err)
2929
}

0 commit comments

Comments
 (0)