Skip to content

Commit b862248

Browse files
committed
add more outputs and mask all outputs
1 parent 4de5711 commit b862248

File tree

3 files changed

+76
-11
lines changed

3 files changed

+76
-11
lines changed

Readme.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,52 @@ Read more on [Turso Database Branches here](https://docs.turso.tech/features/bra
88
You can get your Turso Details using the WebUI or using the Turso CLI.
99
Read more on installing and using the [Turso CLI here](https://docs.turso.tech/cli/introduction)
1010

11+
### Usage
12+
13+
```yaml # .github/workflows/create-branch.yml
14+
name: Create a Turso Database Branch
15+
# The trigger can be changed to any event that you want to trigger the action.
16+
on:
17+
pull_request:
18+
branches:
19+
- main
20+
jobs:
21+
deploy_database:
22+
name: Build and Deploy
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout the repository
26+
uses: actions/checkout@v2
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '22.x'
31+
- name: Create a Turso Database Branch
32+
id: create_turso_db_branch
33+
uses: laudebugs/[email protected]
34+
with:
35+
org: ${{ secrets.TURSO_ORG }} # Your Turso Org Slug
36+
api-token: ${{ secrets.TURSO_API_TOKEN }} # Your Turso Platform API Token
37+
branch-name: 'new-branch'
38+
seed-database-name: 'seed-database' # The name of the seed database
39+
group: 'group-name' # The name of the group where the seed database is created in Turso
40+
# Optional Inputs
41+
overwrite-if-exists: false # Whether or not to overwrite the branch if it already exists
42+
create-auth-token: true # Whether or not to create an auth token for the new branch
43+
auth-token-authorization: 'read-only'
44+
auth-token-expiration: '1d'
45+
# Example usage
46+
- name: Build and Deploy with against the new Database Branch
47+
run: |
48+
npm run build
49+
env:
50+
# Using these outputs is up your usecase
51+
DB_BRANCH_LIBSQL_URL: ${{ steps.create_turso_db_branch.outputs.db_branch_libsql_url }}
52+
DB_BRANCH_HTTP_URL: ${{ steps.create_turso_db_branch.outputs.db_branch_http_url }}
53+
DB_BRANCH_HOSTNAME: ${{ steps.create_turso_db_branch.outputs.db_branch_hostname }}
54+
DB_AUTH_TOKEN: ${{ steps.create_turso_db_branch.outputs.db_jwt_auth_token }}
55+
```
56+
1157
## Action Inputs
1258
1359
| Input | Description | Required | Default |
@@ -67,7 +113,7 @@ If this is set to `true`, the action will create an auth token for the new branc
67113

68114
#### `auth-token-authorization` - Authorization for the new auth token
69115

70-
This input is only used if `create-auth-token` is set to `true`. This input specifies the permissions for the new auth token. The permissions can be `read-only` or `read-write`.
116+
This input is only used if `create-auth-token` is set to `true`. This input specifies the permissions for the new auth token. The permissions can be `read-only` or `read-write`. [Read more on Turso Auth Tokens here](https://docs.turso.tech/sdk/authentication#auth-tokens)
71117

72118
#### `auth-token-expiration` - Expiry for the new auth token
73119

@@ -78,8 +124,20 @@ Examples: `1d`, `1w`, `1m`, `1y`, `2w1d30m`
78124

79125

80126
## Action Outputs
81-
### `db-branch-hostname`
127+
> Note: All the outputs are masked and are not intended to be printed in the logs. You can use these outputs in subsequent steps in the workflow.
128+
129+
### `db_branch_hostname`
82130
The hostname of the new branch created.
131+
The format of the hostname is: `[DB-NAME]-[ORG-NAME].turso.io` where `[DB-NAME]` is the name of the branch and `[ORG-NAME]` is the name of the organization.
132+
133+
### `db_branch_libsql_url`
134+
The URL of the new branch created.
135+
The format of the [URL is: `libsql://[DB-NAME]-[ORG-NAME].turso.io`](https://docs.turso.tech/sdk/authentication#database-url) where `[DB-NAME]` is the name of the branch and `[ORG-NAME]` is the name of the organization.
136+
137+
### `db_branch_http_url`
138+
The HTTP URL of the new branch created.
139+
The format of the URL is: `https://[DB-NAME]-[ORG-NAME].turso.io` where `[DB-NAME]` is the name of the branch and `[ORG-NAME]` is the name of the organization.
83140

84-
### `db-branch-url`
85-
The URL of the new branch created.
141+
### `db_jwt_auth_token`
142+
The JWT Auth Token created for the new branch.
143+
You can use this token to access the new branch. Such as running specific actions against the database.

action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ inputs:
3636
required: false
3737
default: '1d'
3838
outputs:
39-
db-branch-hostname:
39+
db_branch_hostname:
4040
description: 'The host name of the newly created Turso DB Branch.'
41-
db-branch-url:
42-
description: 'The URL of the newly created Turso DB Branch.'
41+
db_branch_libsql_url:
42+
description: 'The Libsql Url of the newly created Turso DB Branch.'
43+
db_branch_http_url:
44+
description: 'The Http URL of the newly created Turso DB Branch.'
45+
db_jwt_auth_token:
46+
description: 'The authentication token for the newly created Turso DB Branch.'
4347
runs:
4448
using: 'node20'
4549
main: 'create-turso-db-branch.mjs'

create-turso-db-branch.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ async function createDatabaseBranch() {
5757
}
5858

5959
/** Pass the database host name to the output */
60-
setOutput('db-branch-url', `libsql://${database.hostname}`)
61-
setOutput('db-branch-hostname', database.hostname)
60+
setSecret(database.hostname)
61+
setOutput('db_branch_libsql_url', `libsql://${database.hostname}`)
62+
setOutput('db_branch_http_url', `https://${database.hostname}`)
63+
setOutput('db_branch_hostname', database.hostname)
6264

6365
/**
6466
* If the createAuthToken option is set to true, create a token for the database
@@ -76,9 +78,10 @@ async function createDatabaseBranch() {
7678
setFailed('Unable to create auth token')
7779
}
7880

81+
/** Set the auth token as a secret */
82+
setSecret(jwtToken.jwt)
7983
/** Return auth token details */
80-
setOutput('jwt-token', jwtToken.jwt)
81-
setSecret('jwt-token')
84+
setOutput('db_jwt_auth_token', jwtToken.jwt)
8285
}
8386
}
8487

0 commit comments

Comments
 (0)