Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atlasaction: support dry-run flag #115

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading