Skip to content

Commit 1b7291d

Browse files
committed
feat: make shopify input conditional
1 parent c954758 commit 1b7291d

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

dist/action.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ function action() {
4747
const PULL_REQUEST = github.context.payload.pull_request;
4848
const REGEX_STRING = `${TRIGGER_PHRASE}(?:\s*)https:\\/\\/app.asana.com\\/(\\d+)\\/(?<project>\\d+)\\/(?<task>\\d+)`;
4949
const REGEX = new RegExp(REGEX_STRING, "g");
50+
const shopifyActions = ["create-theme", "update-theme", "delete-theme"];
51+
const isShopifyAction = shopifyActions.includes(ACTION);
5052
const shopifyAuth = {
51-
password: core.getInput("shopify-password", { required: true }),
52-
storeUrl: core.getInput("shopify-store-url", { required: true }),
53+
password: core.getInput("shopify-password", { required: isShopifyAction }),
54+
storeUrl: core.getInput("shopify-store-url", { required: isShopifyAction }),
5355
themeName: (PULL_REQUEST === null || PULL_REQUEST === void 0 ? void 0 : PULL_REQUEST.head.ref) || "default-ref",
5456
};
5557
const client = yield (0, asana_action_1.buildClient)(ASANA_PAT);
@@ -112,6 +114,7 @@ function action() {
112114
if (comment) {
113115
console.info("removing comment", comment.gid);
114116
try {
117+
//@ts-ignore
115118
yield client.stories.delete(comment.gid);
116119
}
117120
catch (error) {
@@ -164,6 +167,7 @@ function action() {
164167
updatedTask.push(taskId);
165168
return updatedTask;
166169
}
170+
break;
167171
}
168172
case "update-section": {
169173
const targetJSON = core.getInput("targets", { required: true });
@@ -200,6 +204,10 @@ function action() {
200204
yield (0, shopify_1.removeTheme)(shopifyAuth);
201205
break;
202206
}
207+
// case "check-deployment": {
208+
// await checkDeployment(github.context);
209+
// break;
210+
// }
203211
default:
204212
core.setFailed("unexpected action ${ACTION}");
205213
}

dist/asana/asana-action.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3535
exports.updateTask = exports.updateSection = exports.moveSection = exports.migrateSection = exports.findComment = exports.buildClient = exports.addComment = void 0;
3636
const core = __importStar(require("@actions/core"));
3737
const asana = __importStar(require("asana"));
38+
// types not working asana
3839
function moveSection(client, taskId, targets) {
3940
return __awaiter(this, void 0, void 0, function* () {
4041
const task = yield client.tasks.findById(taskId);
@@ -90,6 +91,7 @@ function updateSection(client, targets) {
9091
return;
9192
}
9293
const tasksToUpdate = yield client.tasks
94+
// @ts-ignore
9395
.findBySection(fromSection.gid)
9496
.then((tasks) => tasks.data);
9597
if (target.fieldId) {
@@ -125,6 +127,7 @@ function migrateSection(client, targets) {
125127
return;
126128
}
127129
const tasksToMigrate = yield client.tasks
130+
// @ts-ignore
128131
.findBySection(fromSection.gid)
129132
.then((tasks) => tasks.data);
130133
for (const taskToMigrate of tasksToMigrate) {
@@ -140,6 +143,7 @@ function findComment(client, taskId, commentId) {
140143
let stories;
141144
try {
142145
const storiesCollection = yield client.tasks.stories(taskId);
146+
// @ts-ignore
143147
stories = yield storiesCollection.fetch(200);
144148
}
145149
catch (error) {
@@ -157,6 +161,7 @@ function addComment(client, taskId, commentId, text, isPinned) {
157161
try {
158162
const comment = yield client.tasks.addComment(taskId, {
159163
text: text,
164+
// @ts-ignore
160165
is_pinned: isPinned,
161166
});
162167
return comment;
@@ -171,6 +176,7 @@ function buildClient(asanaPAT) {
171176
return __awaiter(this, void 0, void 0, function* () {
172177
return asana.Client.create({
173178
defaultHeaders: { "asana-enable": "new-sections,string_ids" },
179+
// @ts-ignore
174180
logAsanaChangeWarnings: false,
175181
})
176182
.useAccessToken(asanaPAT)

src/action.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ async function action() {
2424
const PULL_REQUEST = github.context.payload.pull_request;
2525
const REGEX_STRING: string = `${TRIGGER_PHRASE}(?:\s*)https:\\/\\/app.asana.com\\/(\\d+)\\/(?<project>\\d+)\\/(?<task>\\d+)`;
2626
const REGEX = new RegExp(REGEX_STRING, "g");
27+
const shopifyActions = ["create-theme", "update-theme", "delete-theme"];
28+
const isShopifyAction = shopifyActions.includes(ACTION);
2729
const shopifyAuth: ShopifyAuth = {
28-
password: core.getInput("shopify-password", { required: true }),
29-
storeUrl: core.getInput("shopify-store-url", { required: true }),
30+
password: core.getInput("shopify-password", { required: isShopifyAction }),
31+
storeUrl: core.getInput("shopify-store-url", { required: isShopifyAction }),
3032
themeName: PULL_REQUEST?.head.ref || "default-ref",
3133
};
3234

@@ -157,6 +159,7 @@ async function action() {
157159
updatedTask.push(taskId);
158160
return updatedTask;
159161
}
162+
break;
160163
}
161164
case "update-section": {
162165
const targetJSON = core.getInput("targets", { required: true });
@@ -202,6 +205,10 @@ async function action() {
202205
await removeTheme(shopifyAuth);
203206
break;
204207
}
208+
// case "check-deployment": {
209+
// await checkDeployment(github.context);
210+
// break;
211+
// }
205212
default:
206213
core.setFailed("unexpected action ${ACTION}");
207214
}

src/asana/asana-action.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ async function migrateSection(client: Client, targets: UpdateTarget[]) {
129129
core.info(`Moved projects from ${target.from} to ${target.to}`);
130130
}
131131
}
132-
async function findComment(client: Client, taskId: string | number,, commentId: string) {
132+
async function findComment(
133+
client: Client,
134+
taskId: string | number,
135+
commentId: string
136+
) {
133137
let stories;
134138
try {
135139
const storiesCollection = await client.tasks.stories(taskId);
@@ -175,12 +179,11 @@ async function buildClient(asanaPAT: string): Promise<Client> {
175179
}
176180

177181
export {
178-
addComment,
179-
buildClient,
180-
findComment,
181-
migrateSection,
182-
moveSection,
183-
updateSection,
184-
updateTask
182+
addComment,
183+
buildClient,
184+
findComment,
185+
migrateSection,
186+
moveSection,
187+
updateSection,
188+
updateTask,
185189
};
186-

0 commit comments

Comments
 (0)