Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow Project and Task GID to be provided to the action #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ inputs:
description: 'List of allowed projects. The action will not add comments to tasks or subtasks of tasks in any of these projects. Only one of allowed-projects or blocked-projects can be specified.'
required: false
default: ''
asana-project-gid:
description: 'The Asana Project GID to use to link the PR (both task and project GIDs are required)'
required: false
default: ''
asana-task-gid:
description: 'The Asana Task GID to use to link the PR (both task and project GIDs are required)'
required: false
default: ''
outputs:
status:
description: 'status'
Expand Down
7,116 changes: 2,611 additions & 4,505 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions dist/licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -722,19 +722,6 @@ Permission to use, copy, modify, and/or distribute this software for any purpose
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


uuid
MIT
The MIT License (MIT)

Copyright (c) 2010-2020 Robert Kieffer and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


webidl-conversions
BSD-2-Clause
# The BSD 2-Clause License
Expand Down
1 change: 1 addition & 0 deletions src/constants/asana.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const BASE_URL = "https://app.asana.com/0";
2 changes: 2 additions & 0 deletions src/constants/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const ASANA_SECRET = "asana-secret";
export const ASANA_PROJECT_GID = "asana-project-gid";
export const ASANA_TASK_GID = "asana-task-gid";
export const ALLOWED_PROJECTS = "allowed-projects";
export const BLOCKED_PROJECTS = "blocked-projects";
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const run = async () => {
const result = await axios.post(REQUESTS.ACTION_URL, {
allowedProjects,
blockedProjects,
pullRequestDescription: context.payload.pull_request?.body,
pullRequestDescription: utils.createPRDescription(
context.payload.pull_request?.body
),
pullRequestName: context.payload.pull_request?.title,
pullRequestNumber: context.payload.pull_request?.number,
pullRequestURL: context.payload.pull_request?.html_url,
Expand All @@ -25,9 +27,10 @@ const run = async () => {
console.log(result.data);
setOutput("status", result.status);
} catch (error) {
if (utils.isAxiosError(error)) console.log(error.response?.data || "Unknown error");
if (utils.isAxiosError(error))
console.log(error.response?.data || "Unknown error");
if (error instanceof Error) setFailed(error.message);
else setFailed("Unknown error")
else setFailed("Unknown error");
}
};

Expand Down
13 changes: 13 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { AxiosError } from "axios";
import { getInput } from "@actions/core";
import * as ERRORS from "../constants/errors";
import * as TRIGGERS from "../constants/triggers";
import * as INPUTS from "../constants/inputs";
import * as ASANA from "../constants/asana";

export const getProjectsFromInput = (inputName: string): String[] => {
const projects = getInput(inputName);
Expand All @@ -24,3 +26,14 @@ export const validateProjectLists = (
};

export const isAxiosError = (e: any): e is AxiosError => e.isAxiosError;

export const createPRDescription = (prDescription?: string) => {
const projectGid = getInput(INPUTS.ASANA_PROJECT_GID);
const taskGid = getInput(INPUTS.ASANA_TASK_GID);

const asanaTaskLink = `${ASANA.BASE_URL}/${projectGid}/${taskGid}`;

return projectGid && taskGid
? `${prDescription}\n\n${asanaTaskLink}`
: prDescription;
};