Skip to content

Commit 07cafa0

Browse files
committed
check both actionlint.yaml and actionlint.yml on generating a default config file
1 parent 7a24252 commit 07cafa0

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

linter.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,29 +221,33 @@ func (l *Linter) debugWriter() io.Writer {
221221
return l.logOut
222222
}
223223

224-
// GenerateDefaultConfig generates default config file at ".github/actionlint.yaml" in project
224+
// GenerateDefaultConfig generates default config file at ".github/actionlint.yaml" in the project
225225
// which the given directory path belongs to.
226226
func (l *Linter) GenerateDefaultConfig(dir string) error {
227227
l.log("Generating default actionlint.yaml in repository:", dir)
228228

229-
p, err := l.projects.At(dir)
229+
proj, err := l.projects.At(dir)
230230
if err != nil {
231231
return err
232232
}
233-
if p == nil {
233+
if proj == nil {
234234
return errors.New("project is not found. check current project is initialized as Git repository and \".github/workflows\" directory exists")
235235
}
236236

237-
path := filepath.Join(p.RootDir(), ".github", "actionlint.yaml")
238-
if _, err := os.Stat(path); err == nil {
239-
return fmt.Errorf("config file already exists at %q", path)
237+
d := filepath.Join(proj.RootDir(), ".github")
238+
for _, f := range []string{"actionlint.yaml", "actionlint.yml"} {
239+
p := filepath.Join(d, f)
240+
if _, err := os.Stat(p); err == nil {
241+
return fmt.Errorf("config file already exists at %q", p)
242+
}
240243
}
241244

242-
if err := writeDefaultConfigFile(path); err != nil {
245+
p := filepath.Join(d, "actionlint.yaml")
246+
if err := writeDefaultConfigFile(p); err != nil {
243247
return err
244248
}
245249

246-
fmt.Fprintf(l.out, "Config file was generated at %q\n", path)
250+
fmt.Fprintf(l.out, "Config file was generated at %q\n", p)
247251
return nil
248252
}
249253

0 commit comments

Comments
 (0)