Skip to content

Commit

Permalink
atlasaction: support dry-run flag
Browse files Browse the repository at this point in the history
  • Loading branch information
noamcattan committed Feb 13, 2024
1 parent 192481b commit 4afdfe1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions atlasaction/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,22 @@ var Version string

// MigrateApply runs the GitHub Action for "ariga/atlas-action/migrate/apply".
func MigrateApply(ctx context.Context, client *atlasexec.Client, act *githubactions.Action) error {
dryRun, err := func() (bool, error) {
inp := act.GetInput("dry-run")
if inp == "" {
return false, nil
}
return strconv.ParseBool(inp)
}()
if err != nil {
return fmt.Errorf(`invlid value for the "dry-run" input: %w`, err)
}
params := &atlasexec.MigrateApplyParams{
URL: act.GetInput("url"),
DirURL: act.GetInput("dir"),
ConfigURL: act.GetInput("config"),
Env: act.GetInput("env"),
DryRun: dryRun,
TxMode: act.GetInput("tx-mode"), // Hidden param.
BaselineVersion: act.GetInput("baseline"), // Hidden param.
Context: &atlasexec.DeployRunContext{
Expand Down
3 changes: 3 additions & 0 deletions migrate/apply/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ inputs:
env:
description: The environment to use from the Atlas configuration file. For example, `dev`.
required: false
dry-run:
description: Print SQL without executing it. Either "true" or "false".
required: false
outputs:
current:
description: The current version of the database. (before applying migrations)
Expand Down

0 comments on commit 4afdfe1

Please sign in to comment.