-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,58 @@ | ||
# squawk-action | ||
# squawk-action ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/sbdchd/squawk-action?display_name=tag&sort=semver) | ||
|
||
A GitHub Action for [Squawk](https://github.com/sbdchd/squawk). | ||
|
||
Lint Postgres migrations and report violations as a comment in a GitHub Pull Request ([example PR](https://github.com/sbdchd/squawk/pull/14#issuecomment-647009446)). | ||
|
||
For more information on Squawk, see the [Squawk GitHub repository](https://github.com/sbdchd/squawk) or [website](https://squawkhq.com). | ||
|
||
## basic usage | ||
|
||
Lint every .sql file in `migrations/` on every pull request. | ||
|
||
```yml | ||
# .github/workflows/lint-migrations.yml | ||
name: Lint Migrations | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
lint_migrations: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: sbdchd/squawk-action@v1 | ||
with: | ||
pattern: "migrations/*.sql" | ||
version: "latest" | ||
``` | ||
## advanced usage | ||
Only lint modified .sql files in the `migrations/`. | ||
|
||
```yml | ||
# .github/workflows/lint-migrations.yml | ||
name: Lint Migrations | ||
on: pull_request | ||
jobs: | ||
lint_migrations: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Find modified migrations | ||
run: | | ||
modified_migrations=$(git diff --name-only origin/$GITHUB_BASE_REF...origin/$GITHUB_HEAD_REF 'migrations/*.sql') | ||
echo "$modified_migrations" | ||
echo "::set-output name=file_names::$modified_migrations" | ||
id: modified-migrations | ||
- uses: sbdchd/squawk-action@v1 | ||
with: | ||
pattern: ${{ steps.modified-migrations.outputs.file_names }} | ||
``` | ||
|
||
## example report | ||
|
||
[![Example Squawk PR Comment](./squawk-pr-comment.png)](https://github.com/sbdchd/squawk/pull/14#issuecomment-647009446) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: 'Squawk action' | ||
description: 'Lint Postgres migrations with Squawk' | ||
author: sbdchd | ||
branding: | ||
icon: 'check-square' | ||
color: 'blue' | ||
|
||
inputs: | ||
access_token: | ||
description: 'Your GitHub Access Token (default: {{ github.token }})' | ||
default: '${{ github.token }}' | ||
required: true | ||
version: | ||
description: "Squawk NPM version to install (default: latest)" | ||
default: 'latest' | ||
required: true | ||
pattern: | ||
description: "Glob pattern of files to match. (./migrations/*)" | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/setup-node@v3 | ||
- run: npm install -g squawk-cli@${{inputs.version}} | ||
shell: bash | ||
- run: | | ||
export SQUAWK_GITHUB_TOKEN=${{inputs.access_token}} | ||
export SQUAWK_GITHUB_REPO_OWNER=$(jq --raw-output .repository.owner.login "$GITHUB_EVENT_PATH") | ||
export SQUAWK_GITHUB_REPO_NAME=$(jq --raw-output .repository.name "$GITHUB_EVENT_PATH") | ||
export SQUAWK_GITHUB_PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") | ||
squawk --verbose upload-to-github ${{inputs.pattern}} | ||
shell: bash |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.