Skip to content

Commit

Permalink
Attempts to remove the tag from cards.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjthompson805 committed Dec 30, 2020
1 parent 3b4f77c commit b78c458
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
18 changes: 18 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Remove Label from Cards'
description: 'Removes the given label from all cards in the given column.'
inputs:
token:
description: 'github token'
required: true
default: ''
label_to_remove:
description: 'Label to remove'
required: true
default: ''
column_id:
description: 'Column id'
required: true
default: ''
runs:
using: 'node12'
main: 'index.js'
16 changes: 16 additions & 0 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

if [ "$#" != "1" ]
then
echo "USAGE: $0 <commit-message>"
exit
fi

git add -A
git commit -m "$@"
git push origin main
git tag -d v1
git tag -a -m "Release version" v1
git push --delete origin v1
git push origin v1

52 changes: 52 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const core = require('@actions/core');
const github = require('@actions/github');
const token = core.getInput('token');
const labelToRemove = core.getInput('label_to_remove');
const columnId = core.getInput('column_id');
const repoOwner = github.context.repo.owner;
const repo = github.context.repo.repo;
const octokit = github.getOctokit(token);

async function main() {
// Get the cards from the given column
var cards = null;
try {
cards = await octokit.projects.listCards({
column_id: columnId,
archived_state: 'not_archived'
});
}
catch (e) {
console.log(e.message);
return;
}

// Remove the label from the cards
cards.data.forEach(async card => {
if (!card.content_url) {
// This occurs for notes, where the card is not an issue
return true;
}
const matches = card.content_url.match(/\/issues\/(\d+)/);
if (!matches) {
console.log(`Couldn't match the regexp against '${card.content_url}'.`);
return true;
}

const issueNumber = matches[1];
try {
await octokit.issues.removeLabel({
owner: repoOwner,
repo: repo,
issue_number: issueNumber,
name: labelToRemove
});
}
catch (e) {
console.log(e.message);
return true;
}
});
}

main();

0 comments on commit b78c458

Please sign in to comment.