Skip to content

Commit

Permalink
action: added dir-format in input (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
giautm authored May 30, 2023
1 parent 09c2799 commit 6892c0c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inputs:
dir:
description: 'select migration directory relative to working directory'
required: true
dir-format:
description: 'Dir format for migration files ("atlas", "golang-migrate", "flyway")'
required: false
cloud-token:
description: 'Token for using Atlas Cloud (should be passed as a secret).'
required: true
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,18 @@ func Input(act *githubactions.Action) (atlascloud.ReportDirInput, error) {
if err != nil {
return atlascloud.ReportDirInput{}, err
}
dirFormat := atlascloud.DirFormat(strings.ToUpper(act.GetInput("dir-format")))
if dirFormat == "" {
dirFormat = atlascloud.DirFormatAtlas
}
return atlascloud.ReportDirInput{
Repo: fmt.Sprintf("%s/%s", org, repo),
Branch: c.RefName,
Commit: c.SHA,
Path: act.GetInput("dir"),
Url: ev.HeadCommit.URL,
Driver: drv,
DirFormat: atlascloud.DirFormatAtlas,
DirFormat: dirFormat,
ArchiveFormat: atlascloud.ArchiveFormatB64Tar,
}, nil
}
Expand Down
3 changes: 2 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func TestInput(t *testing.T) {
"GITHUB_SHA": "1234567890",
"INPUT_DIR": "migrations/",
"INPUT_DRIVER": tc.db,
"INPUT_DIR-FORMAT": "flyway",
"GITHUB_REF_NAME": "master",
"GITHUB_EVENT_PATH": "internal/testdata/push_event.json",
}
Expand All @@ -66,7 +67,7 @@ func TestInput(t *testing.T) {
Path: "migrations/",
Driver: tc.driver,
Url: "https://github.com/ariga/atlas-sync-action/commit/4a3f0bcb6dff19078393728f1b69d89d853771eb",
DirFormat: atlascloud.DirFormatAtlas,
DirFormat: atlascloud.DirFormatFlyway,
ArchiveFormat: atlascloud.ArchiveFormatB64Tar,
}, input)
})
Expand Down

0 comments on commit 6892c0c

Please sign in to comment.