diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 00000000..b5ede0fc --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,12 @@ +name: Linter + +on: push + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v1 + - name: Run Shellcheck + uses: azohra/shell-linter@latest diff --git a/README.md b/README.md index 8730e3e0..b53dddc4 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ This action helps you to sync your PRs with tasks in Teamwork to streamline team collaboration and your development workflows.

+![Linter](https://github.com/Teamwork/github-sync/workflows/Linter/badge.svg) + ## Getting Started ### Prerequisites diff --git a/entrypoint.sh b/entrypoint.sh index 1c4f1c48..9b3edd58 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,6 +9,7 @@ fi export PROJECT_HOME +# shellcheck disable=SC1090 source "$PROJECT_HOME/src/main.sh" main "$@" diff --git a/src/main.sh b/src/main.sh index 769b2e95..7070cce4 100644 --- a/src/main.sh +++ b/src/main.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# shellcheck disable=SC1090 source "$PROJECT_HOME/src/ensure.sh" source "$PROJECT_HOME/src/github.sh" source "$PROJECT_HOME/src/misc.sh" @@ -26,14 +27,14 @@ main() { exit 0 fi - log::message "Task found with the id: "$task_id + log::message "Task found with the id: $task_id" export TEAMWORK_TASK_ID=$task_id local -r event=$(github::get_event_name) local -r action=$(github::get_action) - log::message "Event: " $event " - Action: " $action + log::message "Event: $event - Action: $action" if [ "$event" == "pull_request" ] && [ "$action" == "opened" ]; then teamwork::pull_request_opened diff --git a/src/teamwork.sh b/src/teamwork.sh index f4faa07e..3b96aaf4 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -4,21 +4,21 @@ teamwork::get_task_id_from_body() { local -r body=$1 pat='tasks\/[0-9]{1,}' - task=$(echo $body | grep -Eo $pat) - task_id=$(echo $task | tr -cd '[[:digit:]]') + task=$(echo "$body" | grep -Eo "$pat") + task_id=$(echo "$task" | tr -cd '[:digit:]') - echo $task_id + echo "$task_id" } teamwork::add_comment() { local -r body=$1 response=$(curl -X "POST" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID/comments.json" \ - -u $TEAMWORK_API_TOKEN':' \ + -u "$TEAMWORK_API_TOKEN"':' \ -H 'Content-Type: application/json; charset=utf-8' \ -d "{ \"comment\": { \"body\": \"$body\", \"notify\": \"\", \"content-type\": \"text\", \"isprivate\": false } }" ) - echo $response + echo "$response" } teamwork::pull_request_opened() {