@@ -12,37 +12,37 @@ inputs:
1212 required : true
1313 type : string
1414 assume-in-transaction :
15- description : ' Assume in transaction'
15+ description : " Assume in transaction"
1616 required : false
17- default : ' false'
17+ default : " false"
1818 type : boolean
1919 exclude :
20- description : ' Rules to exclude, as a comma-separated string'
20+ description : " Rules to exclude, as a comma-separated string"
2121 required : false
2222 type : string
2323 files :
2424 description : " Space separated list of file paths to check. Cannot contain glob patterns."
2525 required : false
26- default : ' '
26+ default : " "
2727 type : string
2828 fail-on-violations :
29- description : ' Fail on violations'
29+ description : " Fail on violations"
3030 required : false
31- default : ' false'
31+ default : " false"
3232 type : boolean
3333 pattern :
3434 description : " Glob pattern of files to match. (./migrations/*)"
3535 required : false
36- default : ' '
36+ default : " "
3737 type : string
3838 pg-version :
39- description : ' PostgreSQL version'
39+ description : " PostgreSQL version"
4040 required : false
4141 type : string
4242 verbose :
43- description : ' Verbose output'
43+ description : " Verbose output"
4444 required : false
45- default : ' true'
45+ default : " true"
4646 type : boolean
4747 version :
4848 description : " Squawk NPM version to install (default: latest)"
@@ -66,43 +66,46 @@ runs:
6666 PATTERN="${{ inputs.pattern }}"
6767 PG_VERSION="${{ inputs.pg-version }}"
6868 VERBOSE="${{ inputs.verbose }}"
69-
69+
7070 COMMAND="squawk"
71-
71+
7272 if "$ASSUME_IN_TRANSACTION"; then
7373 COMMAND="$COMMAND --assume-in-transaction"
7474 fi
75-
75+
7676 if [ -n "$EXCLUDE" ]; then
7777 COMMAND="$COMMAND --exclude=$EXCLUDE"
7878 fi
7979
8080 if [ -n "$PG_VERSION" ]; then
8181 COMMAND="$COMMAND --pg-version=$PG_VERSION"
8282 fi
83-
83+
8484 if "$VERBOSE"; then
8585 COMMAND="$COMMAND --verbose"
8686 fi
87-
88- COMMAND="$COMMAND upload-to-github"
89- if "$FAIL_ON_VIOLATIONS"; then
90- COMMAND="$COMMAND --fail-on-violations"
87+
88+ # We can only leave a comment when we run on pull_request.
89+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
90+ COMMAND="$COMMAND upload-to-github"
91+ if "$FAIL_ON_VIOLATIONS"; then
92+ COMMAND="$COMMAND --fail-on-violations"
93+ fi
9194 fi
9295
9396 if [ -n "$FILES" ]; then
9497 COMMAND="$COMMAND $FILES"
9598 fi
96-
99+
97100 if [ -n "$PATTERN" ]; then
98101 expandedFiles=$(find . \( -path "./$PATTERN" -or -path "$PATTERN" \) -type f | xargs echo)
99102 COMMAND="$COMMAND $expandedFiles"
100103 fi
101-
104+
102105 export SQUAWK_GITHUB_TOKEN=${{inputs.access_token}}
103106 export SQUAWK_GITHUB_REPO_OWNER=$(jq --raw-output .repository.owner.login "$GITHUB_EVENT_PATH")
104107 export SQUAWK_GITHUB_REPO_NAME=$(jq --raw-output .repository.name "$GITHUB_EVENT_PATH")
105108 export SQUAWK_GITHUB_PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
106-
109+
107110 echo "Running: $COMMAND"
108111 sh -c "$COMMAND"
0 commit comments