Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ about: Report a bug to help us improve
title: "[Brief description]"
---

<!-- DO NOT REMOVE THE HEADER -->
<!---HEADER START-->

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

❌ **This issue is not open for contribution. Visit <a href="https://learningequality.org/contributing-to-our-open-code-base/" target="_blank">Contributing guidelines</a>** to learn about the contributing process and how to find suitable issues.

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

<!---HEADER END-->

<!--
Instructions:
* Fill out the sections below, replace …'s with information about your issue
Expand Down
11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/enhancement_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ Instructions:

-->

<!-- DO NOT REMOVE THE HEADER -->
<!---HEADER START-->

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

❌ **This issue is not open for contribution. Visit <a href="https://learningequality.org/contributing-to-our-open-code-base/" target="_blank">Contributing guidelines</a>** to learn about the contributing process and how to find suitable issues.

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

<!---HEADER END-->

## Desired behavior
<!-- Briefly describe the behavior you would like to see -->

Expand Down
11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/epic_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ assignees: ''

---

<!-- DO NOT REMOVE THE HEADER -->
<!---HEADER START-->

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

❌ **This issue is not open for contribution. Visit <a href="https://learningequality.org/contributing-to-our-open-code-base/" target="_blank">Contributing guidelines</a>** to learn about the contributing process and how to find suitable issues.

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

<!---HEADER END-->

_[General guidance: When drafting a feature project, the goal is to create a reference for project scope and context. Write for our core product team. The issue should not be overly technical, and should be be comprehensible and a useful reference to devs, designers, and QA team, to build a shared source of understanding. Anyone at LE should be able to read this and more or less understand the project. If there is relevant information or context that is for the internal team only, please add that in a notion page and link it, rather than adding directly to these issues.]_

## Overview
Expand Down
11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/other_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,4 @@ name: Other issue
about: For issues that don't fit any other category
---

<!-- DO NOT REMOVE THE HEADER -->
<!---HEADER START-->

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

❌ **This issue is not open for contribution. Visit <a href="https://learningequality.org/contributing-to-our-open-code-base/" target="_blank">Contributing guidelines</a>** to learn about the contributing process and how to find suitable issues.

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

<!---HEADER END-->

## Description
12 changes: 0 additions & 12 deletions .github/ISSUE_TEMPLATE/product_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ assignees: ''

---

<!-- DO NOT REMOVE THE HEADER -->
<!---HEADER START-->

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

❌ **This issue is not open for contribution. Visit <a href="https://learningequality.org/contributing-to-our-open-code-base/" target="_blank">Contributing guidelines</a>** to learn about the contributing process and how to find suitable issues.

<img height="20px" src="https://i.imgur.com/c7hUeb5.jpeg">

<!---HEADER END-->


_[General guidance: Product issues should describe the feature, but are not actually technically specced for dev work.]_

## Overview
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/call-manage-issue-header.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Manage issue header

on:
issues:
types: [opened, reopened, labeled, unlabeled]

jobs:
call-workflow:
name: Call shared workflow
uses: learningequality/.github/.github/workflows/manage-issue-header.yml@main
secrets:
LE_BOT_APP_ID: ${{ secrets.LE_BOT_APP_ID }}
LE_BOT_PRIVATE_KEY: ${{ secrets.LE_BOT_PRIVATE_KEY }}
43 changes: 22 additions & 21 deletions .github/workflows/manage-issue-header.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
name: Manage issue header

on:
issues:
types: [labeled, unlabeled]
workflow_call:
secrets:
LE_BOT_APP_ID:
description: "GitHub App ID for authentication"
required: true
LE_BOT_PRIVATE_KEY:
description: "GitHub App Private Key for authentication"
required: true
workflow_call:
secrets:
LE_BOT_APP_ID:
description: "GitHub App ID for authentication"
required: true
LE_BOT_PRIVATE_KEY:
description: "GitHub App Private Key for authentication"
required: true

jobs:
manage-issue-header:
runs-on: ubuntu-latest
if: |
github.event.action == 'opened' ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would need to add the other event names here too, presumably.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks!

github.event.action == 'reopened' ||
(github.event.action == 'labeled' && github.event.label.name == 'help wanted') ||
(github.event.action == 'unlabeled' && github.event.label.name == 'help wanted')
steps:
- name: Generate App Token
- name: Generate GitHub token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.LE_BOT_APP_ID }}
private_key: ${{ secrets.LE_BOT_PRIVATE_KEY }}

- name: Checkout called repository
uses: actions/checkout@v3
- name: Checkout .github repository
uses: actions/checkout@v4
with:
repository: learningequality/.github
ref: main
token: ${{ steps.generate-token.outputs.token }}

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: 20
cache: 'yarn'

- name: Install dependencies
run: npm install
run: yarn install --frozen-lockfile
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is yarn's version of npm ci - I've recently learned it's recommended approach in workflows. This is also a a reason why I am committing yarn.lock. When I have a while, I will upgrade and improve other community related workflows similarly.


- name: Run script
id: run-script
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const script = require('./scripts/manage-issue-header.js');
return await script({github, context, core});
await script({github, context, core});
52 changes: 35 additions & 17 deletions scripts/manage-issue-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,48 @@ function clearHeader(issueBody) {
return issueBody.substring(0, startIndex) + issueBody.substring(endIndex + HEADER_END_MARKER.length).trimStart();
}

function isIssueHelpWanted(issue) {
if (!issue.labels || !issue.labels.length) {
return false;
}
return issue.labels.some(label => label.name === HELP_WANTED_LABEL);
}

module.exports = async ({ github, context, core }) => {
try {
const repoOwner = context.repo.owner;
const repoName = context.repo.repo;
const issueNumber = context.payload.issue.number;
const actionType = context.payload.action;
const labelName = context.payload.label.name;

const labelAdded = actionType === "labeled";
const labelRemoved = actionType === "unlabeled";

if (!labelAdded && !labelRemoved) {
return;
}

if (labelName !== HELP_WANTED_LABEL) {
return;
const labelName = context.payload.label?.name;
let issue = context.payload.issue;
let header = '';

switch (actionType) {
case 'opened':
// also handle pre-existing 'help wanted' label on transferred issues (processed via 'opened' event in a receiving repository)
header = isIssueHelpWanted(issue) ? HELP_WANTED_HEADER : NON_HELP_WANTED_HEADER;
break;
case 'reopened':
// check for pre-existing 'help wanted' label
header = isIssueHelpWanted(issue) ? HELP_WANTED_HEADER : NON_HELP_WANTED_HEADER;
break;
case 'labeled':
if (labelName === HELP_WANTED_LABEL) {
header = HELP_WANTED_HEADER;
}
break;
case 'unlabeled':
if (labelName === HELP_WANTED_LABEL) {
header = NON_HELP_WANTED_HEADER;
}
break;
default:
core.info(`Unsupported action type '${actionType}' or label '${labelName}'. Skipping.`);
return;
}

const issue = await github.rest.issues.get({
issue = await github.rest.issues.get({
owner: repoOwner,
repo: repoName,
issue_number: issueNumber
Expand All @@ -50,11 +72,7 @@ module.exports = async ({ github, context, core }) => {
const currentBody = issue.data.body || "";

let newBody = clearHeader(currentBody);
if (labelAdded) {
newBody = HELP_WANTED_HEADER + newBody;
} else if (labelRemoved) {
newBody = NON_HELP_WANTED_HEADER + newBody;
}
newBody = header + newBody;

await github.rest.issues.update({
owner: repoOwner,
Expand Down
Loading