Skip to content

Commit

Permalink
Install a Bash Linter (#13)
Browse files Browse the repository at this point in the history
* Install a bash linter

* Fix linter

* Add linter badge
  • Loading branch information
miguelbemartin authored Sep 10, 2020
1 parent c2d597f commit cfa936d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
This action helps you to sync your PRs with tasks in Teamwork to streamline team collaboration and your development workflows.
</p>

![Linter](https://github.com/Teamwork/github-sync/workflows/Linter/badge.svg)

## Getting Started

### Prerequisites
Expand Down
1 change: 1 addition & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fi

export PROJECT_HOME

# shellcheck disable=SC1090
source "$PROJECT_HOME/src/main.sh"

main "$@"
Expand Down
5 changes: 3 additions & 2 deletions src/main.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/teamwork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit cfa936d

Please sign in to comment.