From d2e8359971c9056052fa90f2d1ea6b39e85763b0 Mon Sep 17 00:00:00 2001 From: zhouzhuojie Date: Mon, 16 Aug 2021 13:32:40 -0700 Subject: [PATCH] Fix triage workflow when the card already exists in project (#63347) Summary: Fixes issues like https://github.com/pytorch/pytorch/runs/3336787242 ``` RequestError [HttpError]: Validation Failed: {"resource":"ProjectCard","code":"unprocessable","field":"data","message":"Project already has the associated issue"} Error: Unhandled error: HttpError: Validation Failed: {"resource":"ProjectCard","code":"unprocessable","field":"data","message":"Project already has the associated issue"} at /home/runner/work/_actions/actions/github-script/v2/dist/index.js:7531:23 at processTicksAndRejections (internal/process/task_queues.js:93:5) at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:7985:56), :63:1) at async main (/home/runner/work/_actions/actions/github-script/v2/dist/index.js:8011:20) { name: 'HttpError', status: 422, ... ``` The card may already exist, thus no need to handle `422` status code. Anything else will re-throw the err. Pull Request resolved: https://github.com/pytorch/pytorch/pull/63347 Reviewed By: malfet Differential Revision: D30348529 Pulled By: zhouzhuojie fbshipit-source-id: 36647837bfccad43ce01eb5dfe6642e685615037 --- .github/workflows/triage.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index f4466c4..23b2f14 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -83,8 +83,15 @@ jobs: const columnId = filteredColumns[0].id; // Create a project card for this new issue. - await github.projects.createCard({ - column_id: columnId, - content_id: issue.data.id, - content_type: "Issue", - }) + try { + await github.projects.createCard({ + column_id: columnId, + content_id: issue.data.id, + content_type: "Issue", + }) + } catch (err) { + if (err.status !== 422) { + throw err; + } + console.log("Unable to create card: already exists"); + } -- 2.7.4