Skip to content

Commit

Permalink
PBB migration "Move Closed Issues" (hackforla#7056)
Browse files Browse the repository at this point in the history
* Update move-closed-issues.yaml

for migration to PBB

* Update sort-closed-issues.js
  • Loading branch information
t-will-gillis authored Jun 23, 2024
1 parent 5f683ba commit 4b04305
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/move-closed-issues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ on:
issues:
types:
- closed

jobs:
move-closed-issue:
Move-Closed-Issues:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -17,8 +18,9 @@ jobs:
const sortIssues = script({context})
return sortIssues
result-encoding: string
- uses: alex-page/[email protected]
with:
project: Project Board
column: ${{ steps.sort-closed-issues.outputs.result }}
repo-token: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }}

# Post-migration to Projects Beta:
# Move-Closed-Issues to "QA" column by default; OR move to "Done" based on `sort-closed-issues.js`
- name: Move Closed Issues
run: echo "Based on its labels, issue should be sorted to 'status' of '${{ steps.sort-closed-issues.outputs.result }}'"

30 changes: 18 additions & 12 deletions github-actions/move-closed-issues/sort-closed-issues.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const obtainLabels = require('../utils/obtain-labels')

/**
* Check the labels of an issue, and return the column the issue should be sorted into when closed
* Check the labels of an issue, and return the 'status' the issue should be sorted into when closed
* @param {Object} context - context object from actions/github-script
* @returns - returns the appropriate column, which is passed on to the next action
* @returns - returns the appropriate 'status', which is passed on to the next action
*/
function main({ context }) {
const doneColumn = "Done"
const QAColumn = "QA"

// Using Projects Beta 'status'
const doneStatus = "Done"
const QAStatus = "QA"

const hardLabels = [
"Feature: Refactor CSS",
Expand All @@ -32,23 +34,27 @@ function main({ context }) {
// checks if label is an override label
const isOverrideLabel = label => overrideSoftLabels.includes(label);

/** If issue includes hard labels there should be no visual changes - move to the Done column */
/** If issue includes hard labels there should be no visual changes - move to the Done status */
if (issueLabels.some(isHardLabel)) {
return doneColumn;
console.log("Found hard label- sort to 'Done' status.");
return doneStatus;
}

/** if issue does not include a hard label, but does contain an override label - move to QA */
/** if issue does not include a hard label, but does contain an override label - move to QA status */
if (issueLabels.some(isOverrideLabel)) {
return QAColumn;
console.log("Found override label- sort to 'QA' status.");
return QAStatus;
}

/** if issue includes soft labels (no hard or override) - move to Done */
/** if issue includes soft labels (no hard or override) - move to Done status */
if (issueLabels.some(isSoftLabel)) {
return doneColumn;
console.log("Found soft label- sort to 'Done' status.");
return doneStatus;
}

// all other issues go to QA column
return QAColumn;
// all other issues go to QA status
console.log("Didn't find hard or soft label- sort to 'QA' status.");
return QAStatus;
}

module.exports = main;

0 comments on commit 4b04305

Please sign in to comment.