-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempts to remove the tag from cards.
- Loading branch information
1 parent
3b4f77c
commit b78c458
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |