Skip to content

Commit cfa936d

Browse files
Install a Bash Linter (#13)
* Install a bash linter * Fix linter * Add linter badge
1 parent c2d597f commit cfa936d

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

.github/workflows/linter.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Linter
2+
3+
on: push
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v1
11+
- name: Run Shellcheck
12+
uses: azohra/shell-linter@latest

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
This action helps you to sync your PRs with tasks in Teamwork to streamline team collaboration and your development workflows.
1313
</p>
1414

15+
![Linter](https://github.com/Teamwork/github-sync/workflows/Linter/badge.svg)
16+
1517
## Getting Started
1618

1719
### Prerequisites

entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fi
99

1010
export PROJECT_HOME
1111

12+
# shellcheck disable=SC1090
1213
source "$PROJECT_HOME/src/main.sh"
1314

1415
main "$@"

src/main.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22

3+
# shellcheck disable=SC1090
34
source "$PROJECT_HOME/src/ensure.sh"
45
source "$PROJECT_HOME/src/github.sh"
56
source "$PROJECT_HOME/src/misc.sh"
@@ -26,14 +27,14 @@ main() {
2627
exit 0
2728
fi
2829

29-
log::message "Task found with the id: "$task_id
30+
log::message "Task found with the id: $task_id"
3031

3132
export TEAMWORK_TASK_ID=$task_id
3233

3334
local -r event=$(github::get_event_name)
3435
local -r action=$(github::get_action)
3536

36-
log::message "Event: " $event " - Action: " $action
37+
log::message "Event: $event - Action: $action"
3738

3839
if [ "$event" == "pull_request" ] && [ "$action" == "opened" ]; then
3940
teamwork::pull_request_opened

src/teamwork.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ teamwork::get_task_id_from_body() {
44
local -r body=$1
55

66
pat='tasks\/[0-9]{1,}'
7-
task=$(echo $body | grep -Eo $pat)
8-
task_id=$(echo $task | tr -cd '[[:digit:]]')
7+
task=$(echo "$body" | grep -Eo "$pat")
8+
task_id=$(echo "$task" | tr -cd '[:digit:]')
99

10-
echo $task_id
10+
echo "$task_id"
1111
}
1212

1313
teamwork::add_comment() {
1414
local -r body=$1
1515

1616
response=$(curl -X "POST" "$TEAMWORK_URI/projects/api/v1/tasks/$TEAMWORK_TASK_ID/comments.json" \
17-
-u $TEAMWORK_API_TOKEN':' \
17+
-u "$TEAMWORK_API_TOKEN"':' \
1818
-H 'Content-Type: application/json; charset=utf-8' \
1919
-d "{ \"comment\": { \"body\": \"$body\", \"notify\": \"\", \"content-type\": \"text\", \"isprivate\": false } }" )
2020

21-
echo $response
21+
echo "$response"
2222
}
2323

2424
teamwork::pull_request_opened() {

0 commit comments

Comments
 (0)