Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions migrations/deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ steps:
cherry-pick: '2.0,2.1,3.0'
```

### Reprovision Build Environment

```yaml
- uses: red-gate/flyway-actions/migrations/deploy@v2
with:
target-environment: build
target-user: ${{ secrets.DB_USER }}
target-password: ${{ secrets.DB_PASSWORD }}
provision-mode: reprovision
```

## Inputs

| Input | Description | Required | Default |
Expand All @@ -99,6 +110,7 @@ steps:
| `cherry-pick` | Comma-separated list of migration versions to apply | No | |
| `baseline-on-migrate` | Whether to automatically baseline the target database on migrate | No | true |
| `skip-drift-check` | Skip the drift check | No | false |
| `provision-mode` | Controls how Flyway runs the provisioner, if one is configured | No | |
| `working-directory` | Working directory for Flyway | No | |
| `extra-args` | Additional Flyway CLI arguments (e.g. `-sqlMigrationPrefix=M`) | No | |

Expand Down
3 changes: 3 additions & 0 deletions migrations/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ inputs:
working-directory:
description: 'Working directory for Flyway'
required: false
provision-mode:
description: 'Controls how Flyway runs the provisioner, if one is configured'
required: false
extra-args:
description: 'Additional Flyway CLI arguments (e.g. -sqlMigrationPrefix=M)'
required: false
Expand Down
7 changes: 4 additions & 3 deletions migrations/deploy/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10498,7 +10498,7 @@ var un = () => {
let t = [];
e.targetEnvironment && t.push(`-environment=${e.targetEnvironment}`);
let n = e.targetEnvironment && e.targetEnvironment !== "default" ? `-environments.${e.targetEnvironment}.` : "-";
return e.targetUrl && t.push(`${n}url=${e.targetUrl}`), e.targetUser && t.push(`${n}user=${e.targetUser}`), e.targetPassword && t.push(`${n}password=${e.targetPassword}`), e.targetSchemas && t.push(`${n}schemas=${e.targetSchemas}`), e.workingDirectory && t.push(`-workingDirectory=${e.workingDirectory}`), e.extraArgs && t.push(...pn(e.extraArgs)), t;
return e.targetUrl && t.push(`${n}url=${e.targetUrl}`), e.targetUser && t.push(`${n}user=${e.targetUser}`), e.targetPassword && t.push(`${n}password=${e.targetPassword}`), e.targetSchemas && t.push(`${n}schemas=${e.targetSchemas}`), e.provisionMode && t.push(`-provisionMode=${e.provisionMode}`), e.workingDirectory && t.push(`-workingDirectory=${e.workingDirectory}`), e.extraArgs && t.push(...pn(e.extraArgs)), t;
}, xn = (e) => [
"check",
"-drift",
Expand Down Expand Up @@ -10543,7 +10543,7 @@ var un = () => {
}, En = (e, t, n) => {
rn("exit-code", e.toString()), t !== void 0 && rn("migrations-applied", t.toString()), n !== void 0 && rn("schema-version", n);
}, Dn = () => {
let e = tn("target-environment") || void 0, t = tn("target-url") || void 0, n = tn("target-user") || void 0, r = tn("target-password") || void 0, i = tn("target-schemas") || void 0, a = tn("target-migration-version") || void 0, o = tn("cherry-pick") || void 0, s = nn("baseline-on-migrate"), l = nn("skip-drift-check"), u = tn("working-directory");
let e = tn("target-environment") || void 0, t = tn("target-url") || void 0, n = tn("target-user") || void 0, r = tn("target-password") || void 0, i = tn("target-schemas") || void 0, a = tn("target-migration-version") || void 0, o = tn("cherry-pick") || void 0, s = nn("baseline-on-migrate"), l = nn("skip-drift-check"), u = tn("provision-mode") || void 0, d = tn("working-directory");
return {
targetEnvironment: e,
targetUrl: t,
Expand All @@ -10554,7 +10554,8 @@ var un = () => {
cherryPick: o,
baselineOnMigrate: s,
skipDriftCheck: l,
workingDirectory: u ? c.resolve(u) : void 0,
provisionMode: u,
workingDirectory: d ? c.resolve(d) : void 0,
extraArgs: tn("extra-args") || void 0,
deploymentReportName: tn("deployment-report-name") || `flyway-${e ?? "default"}-deployment-report`
};
Expand Down
4 changes: 4 additions & 0 deletions migrations/deploy/src/flyway/arg-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const getCommonArgs = (inputs: FlywayMigrationsDeploymentInputs): string[] => {
args.push(`${targetPrefix}schemas=${inputs.targetSchemas}`);
}

if (inputs.provisionMode) {
args.push(`-provisionMode=${inputs.provisionMode}`);
}

if (inputs.workingDirectory) {
args.push(`-workingDirectory=${inputs.workingDirectory}`);
}
Expand Down
2 changes: 2 additions & 0 deletions migrations/deploy/src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const getInputs = (): FlywayMigrationsDeploymentInputs => {
const cherryPick = core.getInput("cherry-pick") || undefined;
const baselineOnMigrate = core.getBooleanInput("baseline-on-migrate");
const skipDriftCheck = core.getBooleanInput("skip-drift-check");
const provisionMode = core.getInput("provision-mode") || undefined;
const rawWorkingDirectory = core.getInput("working-directory");
const workingDirectory = rawWorkingDirectory ? path.resolve(rawWorkingDirectory) : undefined;
const extraArgs = core.getInput("extra-args") || undefined;
Expand All @@ -28,6 +29,7 @@ const getInputs = (): FlywayMigrationsDeploymentInputs => {
cherryPick,
baselineOnMigrate,
skipDriftCheck,
provisionMode,
workingDirectory,
extraArgs,
deploymentReportName,
Expand Down
1 change: 1 addition & 0 deletions migrations/deploy/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type FlywayMigrationsDeploymentInputs = {
cherryPick?: string;
baselineOnMigrate?: boolean;
skipDriftCheck?: boolean;
provisionMode?: string;
workingDirectory?: string;
extraArgs?: string;
deploymentReportName?: string;
Expand Down
17 changes: 17 additions & 0 deletions migrations/deploy/tests/flyway/arg-builders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ describe("getCommonArgs", () => {
});
});

it("should include provision mode", () => {
const inputs: FlywayMigrationsDeploymentInputs = {
...baseInputs,
provisionMode: "reprovision",
};

const args = getCommonArgs(inputs);

expect(args).toContain("-provisionMode=reprovision");
});

it("should not include provision mode when not set", () => {
const args = getCommonArgs(baseInputs);

expect(args.some((a) => a.includes("provisionMode"))).toBe(false);
});

it("should include working directory", () => {
const inputs: FlywayMigrationsDeploymentInputs = {
...baseInputs,
Expand Down
34 changes: 23 additions & 11 deletions state/deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,31 @@ steps:
script-path: deployment.sql
```

### Reprovision Build Environment

```yaml
- uses: red-gate/flyway-actions/state/deploy@v2
with:
target-environment: build
target-user: ${{ secrets.DB_USER }}
target-password: ${{ secrets.DB_PASSWORD }}
provision-mode: reprovision
```

## Inputs

| Input | Description | Required | Default |
|----------------------|--------------------------------------------------|------------------------------------------|------------------------------------------------------|
| `script-path` | Path to the script to deploy | No | `deployments/D__<target-environment>_deployment.sql` |
| `target-environment` | Target database to deploy to | Required if `target-url` not set | |
| `target-url` | JDBC URL for the target database | Required if `target-environment` not set | |
| `target-user` | Database user | No | |
| `target-password` | Database password | No | |
| `target-schemas` | Comma-separated list of schemas | No | |
| `skip-drift-check` | Skip the drift check | No | false |
| `working-directory` | Working directory for Flyway | No | |
| `extra-args` | Additional Flyway CLI arguments | No | |
| Input | Description | Required | Default |
|----------------------|----------------------------------------------------------------|------------------------------------------|------------------------------------------------------|
| `script-path` | Path to the script to deploy | No | `deployments/D__<target-environment>_deployment.sql` |
| `target-environment` | Target database to deploy to | Required if `target-url` not set | |
| `target-url` | JDBC URL for the target database | Required if `target-environment` not set | |
| `target-user` | Database user | No | |
| `target-password` | Database password | No | |
| `target-schemas` | Comma-separated list of schemas | No | |
| `skip-drift-check` | Skip the drift check | No | false |
| `provision-mode` | Controls how Flyway runs the provisioner, if one is configured | No | |
| `working-directory` | Working directory for Flyway | No | |
| `extra-args` | Additional Flyway CLI arguments | No | |

### Deployment Report Upload

Expand Down
3 changes: 3 additions & 0 deletions state/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ inputs:
working-directory:
description: 'Working directory for Flyway'
required: false
provision-mode:
description: 'Controls how Flyway runs the provisioner, if one is configured'
required: false
extra-args:
description: 'Additional Flyway CLI arguments'
required: false
Expand Down
7 changes: 4 additions & 3 deletions state/deploy/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10498,7 +10498,7 @@ var un = () => {
let t = [];
e.targetEnvironment && t.push(`-environment=${e.targetEnvironment}`);
let n = e.targetEnvironment && e.targetEnvironment !== "default" ? `-environments.${e.targetEnvironment}.` : "-";
return e.targetUrl && t.push(`${n}url=${e.targetUrl}`), e.targetUser && t.push(`${n}user=${e.targetUser}`), e.targetPassword && t.push(`${n}password=${e.targetPassword}`), e.targetSchemas && t.push(`${n}schemas=${e.targetSchemas}`), e.workingDirectory && t.push(`-workingDirectory=${e.workingDirectory}`), e.extraArgs && t.push(...pn(e.extraArgs)), t;
return e.targetUrl && t.push(`${n}url=${e.targetUrl}`), e.targetUser && t.push(`${n}user=${e.targetUser}`), e.targetPassword && t.push(`${n}password=${e.targetPassword}`), e.targetSchemas && t.push(`${n}schemas=${e.targetSchemas}`), e.provisionMode && t.push(`-provisionMode=${e.provisionMode}`), e.workingDirectory && t.push(`-workingDirectory=${e.workingDirectory}`), e.extraArgs && t.push(...pn(e.extraArgs)), t;
}, xn = (e) => [
"check",
"-drift",
Expand Down Expand Up @@ -10533,7 +10533,7 @@ var un = () => {
}, Tn = (e) => {
rn("exit-code", e.toString());
}, En = () => {
let e = tn("target-environment") || void 0, t = tn("script-path") || c.join("deployments", `D__${e ?? "default"}_deployment.sql`), n = tn("target-url") || void 0, r = tn("target-user") || void 0, i = tn("target-password") || void 0, a = tn("target-schemas") || void 0, o = nn("skip-drift-check"), s = tn("working-directory");
let e = tn("target-environment") || void 0, t = tn("script-path") || c.join("deployments", `D__${e ?? "default"}_deployment.sql`), n = tn("target-url") || void 0, r = tn("target-user") || void 0, i = tn("target-password") || void 0, a = tn("target-schemas") || void 0, o = nn("skip-drift-check"), s = tn("provision-mode") || void 0, l = tn("working-directory");
return {
scriptPath: t,
targetEnvironment: e,
Expand All @@ -10542,7 +10542,8 @@ var un = () => {
targetPassword: i,
targetSchemas: a,
skipDriftCheck: o,
workingDirectory: s ? c.resolve(s) : void 0,
provisionMode: s,
workingDirectory: l ? c.resolve(l) : void 0,
extraArgs: tn("extra-args") || void 0,
deploymentReportName: tn("deployment-report-name") || `flyway-${e ?? "default"}-deployment-report`
};
Expand Down
4 changes: 4 additions & 0 deletions state/deploy/src/flyway/arg-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const getCommonArgs = (inputs: FlywayStateDeploymentInputs): string[] => {
args.push(`${targetPrefix}schemas=${inputs.targetSchemas}`);
}

if (inputs.provisionMode) {
args.push(`-provisionMode=${inputs.provisionMode}`);
}

if (inputs.workingDirectory) {
args.push(`-workingDirectory=${inputs.workingDirectory}`);
}
Expand Down
2 changes: 2 additions & 0 deletions state/deploy/src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const getInputs = (): FlywayStateDeploymentInputs => {
const targetPassword = core.getInput("target-password") || undefined;
const targetSchemas = core.getInput("target-schemas") || undefined;
const skipDriftCheck = core.getBooleanInput("skip-drift-check");
const provisionMode = core.getInput("provision-mode") || undefined;
const rawWorkingDirectory = core.getInput("working-directory");
const workingDirectory = rawWorkingDirectory ? path.resolve(rawWorkingDirectory) : undefined;
const extraArgs = core.getInput("extra-args") || undefined;
Expand All @@ -25,6 +26,7 @@ const getInputs = (): FlywayStateDeploymentInputs => {
targetPassword,
targetSchemas,
skipDriftCheck,
provisionMode,
workingDirectory,
extraArgs,
deploymentReportName,
Expand Down
1 change: 1 addition & 0 deletions state/deploy/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type FlywayStateDeploymentInputs = {
targetPassword?: string;
targetSchemas?: string;
skipDriftCheck?: boolean;
provisionMode?: string;
workingDirectory?: string;
extraArgs?: string;
deploymentReportName?: string;
Expand Down
17 changes: 17 additions & 0 deletions state/deploy/tests/flyway/arg-builders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ describe("getCommonArgs", () => {
});
});

it("should include provision mode", () => {
const inputs: FlywayStateDeploymentInputs = {
...baseInputs,
provisionMode: "reprovision",
};

const args = getCommonArgs(inputs);

expect(args).toContain("-provisionMode=reprovision");
});

it("should not include provision mode when not set", () => {
const args = getCommonArgs(baseInputs);

expect(args.some((a) => a.includes("provisionMode"))).toBe(false);
});

it("should include working directory", () => {
const inputs: FlywayStateDeploymentInputs = {
...baseInputs,
Expand Down
Loading
Loading