Skip to content

Commit

Permalink
✨ replace url by address input
Browse files Browse the repository at this point in the history
  • Loading branch information
Odonno committed May 25, 2023
1 parent 38f1836 commit 4370d5e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 14 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ jobs:
- name: Apply migrations
uses: Odonno/[email protected]
with:
url: "cloud.surrealdb.com"
address: "wss://cloud.surrealdb.com"
```
## Inputs
| Name | Required | Description | Type | Default |
| ---------- | :------: | ------------------------------------------------------------- | ------ | -------------- |
| `version` | | The version of `surrealdb-migrations` that will be installed. | string | latest |
| `url` | | Url of the surrealdb instance. | string | localhost:8000 |
| `ns` | | Namespace to use inside the surrealdb instance. | string | test |
| `db` | | Name of the database to use inside the surrealdb instance. | string | test |
| `username` | | Username used to authenticate to the surrealdb instance. | string | root |
| `password` | | Password used to authenticate to the surrealdb instance. | string | root |
| Name | Required | Description | Type | Default |
| ---------- | :------: | ------------------------------------------------------------- | ------ | ------------------- |
| `version` | | The version of `surrealdb-migrations` that will be installed. | string | latest |
| `address` | | Address of the surrealdb instance. | string | ws://localhost:8000 |
| `ns` | | Namespace to use inside the surrealdb instance. | string | test |
| `db` | | Name of the database to use inside the surrealdb instance. | string | test |
| `username` | | Username used to authenticate to the surrealdb instance. | string | root |
| `password` | | Password used to authenticate to the surrealdb instance. | string | root |

Note that you can still make use of the `.surrealdb` configuration file in your project.

Expand Down
4 changes: 2 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import getActionInputs from "../src/args";
test("action inputs should be resolved from env vars", () => {
const testEnvVars = {
INPUT_VERSION: "0.9.5",
INPUT_URL: "localhost:8000",
INPUT_ADDRESS: "ws://localhost:8000",
INPUT_NS: "ns",
INPUT_DB: "db",
};
Expand All @@ -15,7 +15,7 @@ test("action inputs should be resolved from env vars", () => {
const input = getActionInputs();

expect(input.requestedVersion).toBe("0.9.5");
expect(input.url).toBe("localhost:8000");
expect(input.address).toBe("ws://localhost:8000");
expect(input.ns).toBe("ns");
expect(input.db).toBe("db");
expect(input.username).toBe("");
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ inputs:
required: true
default: "latest"

url:
description: "Url of the surrealdb instance"
address:
description: "Address of the surrealdb instance"
required: false

ns:
Expand Down
5 changes: 5 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { input } from "@actions-rs/core";

export type ActionInputs = {
requestedVersion: string;
address: string;
/**
* @deprecated You should use `address` instead (since v0.9.6).
*/
url: string;
ns: string;
db: string;
Expand All @@ -11,6 +15,7 @@ export type ActionInputs = {

export default function getActionInputs(): ActionInputs {
const requestedVersion = input.getInput("version");
const address = input.getInput("address");
const url = input.getInput("url");
const ns = input.getInput("ns");
const db = input.getInput("db");
Expand All @@ -19,6 +24,7 @@ export default function getActionInputs(): ActionInputs {

return {
requestedVersion,
address,
url,
ns,
db,
Expand Down
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ async function run(): Promise<void> {

const additionalArgs: string[] = [];

if (inputs.address) {
additionalArgs.push("--address", inputs.address);
}
if (inputs.url) {
additionalArgs.push("--url", inputs.url);
}
Expand Down

0 comments on commit 4370d5e

Please sign in to comment.