async function replaceIssueCardWithPRCard(octokit, prID){
    console.log("replaceIssueCardWithPRCard");
    // Find ID of column the card is currently in, using requestColumn action input.
    var colID = await getColumnIDByName(octokit, 'requestColumn');
    if (colID == 0) {
        throw "Column not found.";
    }
    
    // List cards in that column.
    // https://octokit.github.io/rest.js/v17#projects-list-cards
    // TODO only gets first page, paginate to get more than 30 cards
    console.log("Cards list for column 'requestColumn'");
    var resp = await octokit.projects.listCards({
        column_id: colID,
        archived_state: 'not_archived',
    });
    console.log(resp.status);
    
    // Get ID of card to move, by matching issue URLs.
    // https://developer.github.com/v3/projects/cards/#get-a-project-card
    // resp.data.[].content_url is the URL of the issue associated with the card
    // e.g. 'https://api.github.com/repos/nostarch-foundation/grant-actions/issues/8'
    // github.context.payload.url is same URL from webhook payload on issue event
    var cardID = 0;
    for (const card of resp.data) {
        if (card.content_url == github.context.payload.issue.url) {
            cardID = card.id;
            break;
        }
    }
    if (cardID == 0) {
        console.log("Card for issue " + github.context.payload.issue.url + " not found.");
        console.log("Assuming it has already been archived. Continuing...");
    } else {
        // https://octokit.github.io/rest.js/v17#projects-update-card
        resp = await octokit.projects.updateCard({
            card_id: cardID,
            archived: true  // Archive the old card.
        });
        console.log("Archived card " + github.context.payload.issue.url);
        console.log(resp.status);
    }
    
    // Create a new card to replace the old one.
    // Find ID of column to put card in.
    var reviewColID = await getColumnIDByName(octokit, 'reviewColumn');
    if (reviewColID == 0) {
        throw "Column 'reviewColumn' not found.";
    }
    console.log("Creating card for PR with ID " + prID);
    resp = await octokit.projects.createCard({
        column_id: reviewColID,
        content_id: prID,
        content_type: "PullRequest"
    })
    console.log("Created card for PR " + prID);
    console.log(resp);
}
// number; the ID is a random number which must be retrieved using the GH API.
number; the ID is a random number which must be retrieved using the GH API.
number ; the ID is a random number which must be retrieved using the GH API .
async function replaceIssueCardWithPRCard(octokit, prID){
    console.log("replaceIssueCardWithPRCard");
    var colID = await getColumnIDByName(octokit, 'requestColumn');
    if (colID == 0) {
        throw "Column not found.";
    }
    console.log("Cards list for column 'requestColumn'");
    var resp = await octokit.projects.listCards({
        column_id: colID,
        archived_state: 'not_archived',
    });
    console.log(resp.status);
    var cardID = 0;
    for (const card of resp.data) {
        if (card.content_url == github.context.payload.issue.url) {
            cardID = card.id;
            break;
        }
    }
    if (cardID == 0) {
        console.log("Card for issue " + github.context.payload.issue.url + " not found.");
        console.log("Assuming it has already been archived. Continuing...");
    } else {
        resp = await octokit.projects.updateCard({
            card_id: cardID,
            archived: true  
        });
        console.log("Archived card " + github.context.payload.issue.url);
        console.log(resp.status);
    }
    var reviewColID = await getColumnIDByName(octokit, 'reviewColumn');
    if (reviewColID == 0) {
        throw "Column 'reviewColumn' not found.";
    }
    console.log("Creating card for PR with ID " + prID);
    resp = await octokit.projects.createCard({
        column_id: reviewColID,
        content_id: prID,
        content_type: "PullRequest"
    })
    console.log("Created card for PR " + prID);
    console.log(resp);
}
async function replaceIssueCardWithPRCard ( octokit , prID ) { console . log ( "replaceIssueCardWithPRCard" ) ; var colID = await getColumnIDByName ( octokit , 'requestColumn' ) ; if ( colID == 0 ) { throw "Column not found." ; } console . log ( "Cards list for column 'requestColumn'" ) ; var resp = await octokit . projects . listCards ( { column_id : colID , archived_state : 'not_archived' , } ) ; console . log ( resp . status ) ; var cardID = 0 ; for ( const card of resp . data ) { if ( card . content_url == github . context . payload . issue . url ) { cardID = card . id ; break ; } } if ( cardID == 0 ) { console . log ( "Card for issue " + github . context . payload . issue . url + " not found." ) ; console . log ( "Assuming it has already been archived. Continuing..." ) ; } else { resp = await octokit . projects . updateCard ( { card_id : cardID , archived : true } ) ; console . log ( "Archived card " + github . context . payload . issue . url ) ; console . log ( resp . status ) ; } var reviewColID = await getColumnIDByName ( octokit , 'reviewColumn' ) ; if ( reviewColID == 0 ) { throw "Column 'reviewColumn' not found." ; } console . log ( "Creating card for PR with ID " + prID ) ; resp = await octokit . projects . createCard ( { column_id : reviewColID , content_id : prID , content_type : "PullRequest" } ) console . log ( "Created card for PR " + prID ) ; console . log ( resp ) ; }
number; the ID is a random number which must be retrieved using the GH API.
number ; the ID is a random number which must be retrieved using the GH API .
// Find ID of column the card is currently in, using requestColumn action input. // List cards in that column. // https://octokit.github.io/rest.js/v17#projects-list-cards // TODO only gets first page, paginate to get more than 30 cards // Get ID of card to move, by matching issue URLs. // https://developer.github.com/v3/projects/cards/#get-a-project-card // resp.data.[].content_url is the URL of the issue associated with the card // e.g. 'https://api.github.com/repos/nostarch-foundation/grant-actions/issues/8' // github.context.payload.url is same URL from webhook payload on issue event // https://octokit.github.io/rest.js/v17#projects-update-card // Archive the old card. // Create a new card to replace the old one. // Find ID of column to put card in.