diff --git a/README.md b/README.md index 52e9794b..30a43573 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@

- This action helps you to sync your PRs with tasks in Teamwork to streamline team collaboration and your development workflows. + 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) @@ -21,7 +21,7 @@ Create the next environment vars in your repository: * `TEAMWORK_URI`: The URL of your installation (e.g.: https://yourcompany.teamwork.com) * `TEAMWORK_API_TOKEN`: The API token to authenticate the workflow. Follow [this guide](https://developer.teamwork.com/guides/api-key-url/) to find your URL and API key. -**Please Note:** The Teamwork account associated with this API key is the account which these comments will be created under. If this user does not have permission to access the project, this action will be ignored. +**Please Note:** The Teamwork account associated with this API key is the account which these comments will be created under. If this user does not have permission to access the project, this action will be ignored. `GITHUB_TOKEN` doesn't need to be setup in the repository, this var is always available during the workflows execution. @@ -51,13 +51,15 @@ jobs: BOARD_COLUMN_OPENED: 'PR Open' BOARD_COLUMN_MERGED: 'Ready to Test' BOARD_COLUMN_CLOSED: 'Rejected' + env: + IGNORE_PROJECT_IDS="1,2,3" ``` ## Usage -When creating a new PR, write in the description of the PR the URL of the task. The action will automatically add a comment in the task. +When creating a new PR, write in the description of the PR the URL of the task. The action will automatically add a comment in the task. -Please note, the comment will be created in Teamwork under the account you have attached to this action. If the API key of the user you are using does not have permissions to access certain projects, the comment will not be created. +Please note, the comment will be created in Teamwork under the account you have attached to this action. If the API key of the user you are using does not have permissions to access certain projects, the comment will not be created. ![GitHub pr comment](./.github/assets/github_pr_comment.png) diff --git a/src/main.sh b/src/main.sh index 4ec5a3e4..63705926 100644 --- a/src/main.sh +++ b/src/main.sh @@ -46,6 +46,13 @@ main() { project_id="$(teamwork::get_project_id_from_task "$task_id")" export TEAMWORK_PROJECT_ID=$project_id + ignored_project_ids=("$IGNORE_PROJECT_IDS") + if (( ${#ignored_project_ids[@]} != 0 )) || utils::in_array "$1" "${ignored_project_ids[*]}" + then + log::message "ignored due to IGNORE_PROJECT_IDS" + exit 0 + fi + if [ "$event" == "pull_request" ] && [ "$action" == "opened" ]; then teamwork::pull_request_opened elif [ "$event" == "pull_request" ] && [ "$action" == "closed" ]; then diff --git a/src/misc.sh b/src/misc.sh index a9436358..fe935ea9 100644 --- a/src/misc.sh +++ b/src/misc.sh @@ -16,3 +16,15 @@ env::set_environment() { export ENV="prod" fi } + +utils::in_array() { + ARRAY=$2 + for e in ${ARRAY[*]} + do + if [[ "$e" == "$1" ]] + then + return 0 + fi + done + return 1 +}