Skip to content

Commit daec8ac

Browse files
authored
Merge pull request #4 from gfx/gfx/tweaks
cleanup & tweaks the code
2 parents e7d182f + ef7acd4 commit daec8ac

File tree

6 files changed

+123
-268
lines changed

6 files changed

+123
-268
lines changed

.github/workflows/example.yaml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: SQLDef Preview Example
1+
name: SQLDef Preview
22

33
on:
44
pull_request:
@@ -8,7 +8,7 @@ permissions:
88
pull-requests: write
99

1010
jobs:
11-
postgresql-preview:
11+
psqldef-preview:
1212
runs-on: ubuntu-latest
1313

1414
services:
@@ -45,9 +45,9 @@ jobs:
4545
pg-host: localhost
4646
pg-port: 5432
4747
pg-database: testdb
48-
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
github-token: ${{ github.token }}
4949

50-
mysql-preview:
50+
mysqldef-preview:
5151
runs-on: ubuntu-latest
5252

5353
services:
@@ -83,9 +83,9 @@ jobs:
8383
mysql-host: 127.0.0.1
8484
mysql-port: 3306
8585
mysql-database: testdb
86-
github-token: ${{ secrets.GITHUB_TOKEN }}
86+
github-token: ${{ github.token }}
8787

88-
sqlite-preview:
88+
sqlite3def-preview:
8989
runs-on: ubuntu-latest
9090

9191
steps:
@@ -103,9 +103,9 @@ jobs:
103103
baseline-schema-file: examples/sqlite3def-current.sql
104104
schema-file: examples/sqlite3def-desired.sql
105105
sqlite-database: test.db
106-
github-token: ${{ secrets.GITHUB_TOKEN }}
106+
github-token: ${{ github.token }}
107107

108-
mssql-preview:
108+
mssqldef-preview:
109109
runs-on: ubuntu-latest
110110

111111
services:
@@ -124,8 +124,7 @@ jobs:
124124
- 1433:1433
125125

126126
steps:
127-
- name: Checkout code
128-
uses: actions/checkout@v5
127+
- uses: actions/checkout@v5
129128
with:
130129
fetch-depth: 0
131130

@@ -154,4 +153,4 @@ jobs:
154153
mssql-host: localhost
155154
mssql-port: 1433
156155
mssql-database: testdb
157-
github-token: ${{ secrets.GITHUB_TOKEN }}
156+
github-token: ${{ github.token }}

README.md

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![CI](https://github.com/gfx/sqldef-preview-action/actions/workflows/ci.yaml/badge.svg)](https://github.com/gfx/sqldef-preview-action/actions/workflows/ci.yaml)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
55

6-
A GitHub Action that previews SQL schema migrations of [sqldef](https://github.com/sqldef/sqldef) on pull requests. It automatically generates a preview of schema changes between your base branch and PR branch, posting the DDLs as a comment on your pull request.
6+
A GitHub Action that previews SQL schema migrations of [sqldef](https://github.com/sqldef/sqldef) on pull requests. It automatically generates a preview of schema changes between your base branch and PR branch, posting the migration DDL as a comment on your pull request.
77

88
## Features
99

@@ -69,6 +69,7 @@ jobs:
6969
pg-user: postgres
7070
pg-password: postgres
7171
pg-database: testdb
72+
github-token: ${{ github.token }}
7273
```
7374
7475
### MySQL Example
@@ -105,6 +106,7 @@ jobs:
105106
mysql-password: testpassword
106107
mysql-host: 127.0.0.1
107108
mysql-database: testdb
109+
github-token: ${{ github.token }}
108110
```
109111
110112
### SQLite Example
@@ -115,6 +117,7 @@ jobs:
115117
command: sqlite3def
116118
schema-file: schema/database.sql
117119
sqlite-database: test.db
120+
github-token: ${{ github.token }}
118121
```
119122
120123
### SQL Server Example
@@ -160,6 +163,7 @@ jobs:
160163
mssql-user: SA
161164
mssql-password: YourStrong@Passw0rd
162165
mssql-database: testdb
166+
github-token: ${{ github.token }}
163167
```
164168
165169
## Input Parameters
@@ -170,15 +174,14 @@ jobs:
170174
|-----------|-------------|----------|
171175
| `command` | SQLDef command to use: `psqldef`, `mysqldef`, `sqlite3def`, or `mssqldef` | ✅ |
172176
| `schema-file` | Path to the SQL schema file | ✅ |
177+
| `github-token` | GitHub token for commenting on pull requests | ✅ |
173178

174179
### Optional Parameters
175180

176181
| Parameter | Description | Default |
177182
|-----------|-------------|---------|
178-
| `version` | Version of sqldef to use (e.g., `v3.0.0` or `latest`) | `v3.0.0` |
179-
| `baseline-schema-file` | Path to baseline schema file for comparison | Auto-fetched from base branch |
183+
| `version` | Version of sqldef to use (e.g., `v3.0.1` or `latest`) | `v3.0.1` |
180184
| `config-file` | Path to sqldef config file | - |
181-
| `github-token` | GitHub token for commenting on pull requests | `${{ github.token }}` |
182185

183186
### PostgreSQL Parameters
184187

@@ -216,47 +219,6 @@ jobs:
216219
| `mssql-port` | SQL Server port | `1433` |
217220
| `mssql-database` | SQL Server database name | - |
218221

219-
## Advanced Configuration
220-
221-
### Using sqldef Config Files
222-
223-
You can use sqldef configuration files for additional settings:
224-
225-
```yaml
226-
- uses: gfx/sqldef-preview-action@v1
227-
with:
228-
command: psqldef
229-
schema-file: schema/database.sql
230-
config-file: .sqldef.yaml
231-
# ... database connection parameters
232-
```
233-
234-
### Multiple Database Types
235-
236-
You can test against multiple database types in parallel:
237-
238-
```yaml
239-
jobs:
240-
preview-postgresql:
241-
# PostgreSQL configuration as shown above
242-
243-
preview-mysql:
244-
# MySQL configuration as shown above
245-
246-
preview-sqlite:
247-
runs-on: ubuntu-latest
248-
steps:
249-
- uses: actions/checkout@v5
250-
with:
251-
fetch-depth: 0
252-
253-
- uses: gfx/sqldef-preview-action@v1
254-
with:
255-
command: sqlite3def
256-
schema-file: schema/database.sql
257-
sqlite-database: test.db
258-
```
259-
260222
## Example PR Comment
261223

262224
When schema changes are detected, the action posts a comment like this:
@@ -269,7 +231,7 @@ ALTER TABLE users ADD COLUMN email VARCHAR(255) NULL;
269231
CREATE INDEX idx_users_email ON users(email);
270232
~~~
271233
272-
This comment was created by sqldef-preview-action.
234+
This comment was generated by [SQLDef Preview](https://github.com/YOUR_ORGANIZATION/YOUR_REPO/actions/runs/RUN_ID), powered by [sqldef/sqldef-preview-action](https://github.com/sqldef/sqldef-preview-action).
273235
```
274236

275237
## Development

action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'SQLDef Preview'
2-
description: 'Preview schema changes using sqldef in pull requests'
2+
description: 'Preview how sqldef migration performs in pull requests'
33
author: 'The sqldef team'
44
branding:
55
icon: 'database'
@@ -17,7 +17,7 @@ inputs:
1717
version:
1818
description: 'Version of sqldef to use'
1919
required: false
20-
default: 'v3.0.0'
20+
default: 'v3.0.1'
2121
config-file:
2222
description: 'Path to sqldef config file'
2323
required: false
@@ -83,7 +83,7 @@ inputs:
8383
# GitHub token for PR comments
8484
github-token:
8585
description: 'GitHub token for commenting on pull requests'
86-
required: false
86+
required: true
8787

8888
runs:
8989
using: 'node24'

0 commit comments

Comments
 (0)