Skip to content

Commit

Permalink
Fix bug and consolidate "Schedule Thursday" into "Schedule Monthly" 4…
Browse files Browse the repository at this point in the history
…788 (#5467)

* Update schedule-monthly.yml

Combining functionalities of prev. `schedule-monthly.yml` and `schedule-thu-1100.yml`

* Update contributors-data.js

Consolidate previous `schedule-monthly.yml` and `schedule-thu-1100.yml`

* Update create-new-issue.js

* Update comment-issue.js

Consolidate `schedule-monthly.yml` and `schedule-thu-1100.yml`

* Update create-new-issue.js

Address CodeQL notice

* Delete github-actions/trigger-schedule/list-inactive-members/get-list.js

No longer used

* Delete .github/workflows/schedule-monthly-PREV.yml

Consolidated functionality into revised `schedule-monthly.yml`

* Update create-new-issue.js

changed 'Website' team to 'website-write' team in the paragraph beginning "If this was a mistake..."

* Update create-new-issue.js

Remove `ready for product` label

* Update create-new-issue.js

Comments from Bonnie #4788 (comment)

* Update schedule-monthly.yml

Bump actions/setup-node@v3 --> @v4 per #5769

* Update contributors-data.js

Removing import references to 'true-github-contributors'- this is not actually used in this file.

* Update create-new-issue.js

Changes in response to Bonnnie's comments

* Update create-new-issue.js

Fixed `milestone` to be `8`, which is the HfLA milestone number corresponding to ".08 Team workflow".

Also, minor edits to the formatting of the message.

* Create schedule-monthly-PREV.yml

Fixing merge conflict:  The "to be deleted" file has changed. Adding file back with the changes, then will immediately delete it again.

* Delete .github/workflows/schedule-monthly-PREV.yml

* Create schedule-monthly-PREV.yml

Adding this file back in in order to address the merge conflict. Once this PR is merged, a follow up PR will delete this file.

* Update create-new-issue.js

Added notes to Dev Leads explaining process to reactivate members, and investigate if a bug is noticed

* Update contributors-data.js

Changed so that only issue assignees are returned when querying "/issues".

* Update contributors-data.js

minor tweaks

* Update schedule-monthly.yml

Update actions/github-script@v6 --> v7

* Create wr-schedule-monthly.yml

Workflow run to automatically close the issue created by the 'Schedule Monthly' workflow

* Update create-new-issue.js

* Create schedule-monthly-reopen.yml

* Update schedule-monthly-PREV.yml

updating actions/github-script@v6 --> v7 per #5899

* Update schedule-monthly.yml

Adding check to skip run on January 1st (since December is off for HfLA website)

* Update contributors-data.js

Adding checks to skip the January 1st run, and adjust to 3 months inactive only for the February 1st run

* Update wr-schedule-monthly.yml

Corrected the name of the GH_TOKEN

* Update schedule-monthly-reopen.yml

Corrected name of repo-token

* Update issue-trigger.yml

latest updates for Inactive Members

* Delete .github/workflows/schedule-monthly-reopen.yml

The reopening mechanism will be different; this workflow no longer needed

* Update check-labels.js

latest with new mechanism for inactive members to create issues

* Update create-new-issue.js

new mechanism for inactive members to send message

* Update create-new-issue.js

Demo video slowed down

* Update contributors-data.js

f. ER#4541: add check to see if inactive member on 'website' team prior to removal from 'website-write' team

* Update create-new-issue.js

uploaded new demo gif
  • Loading branch information
t-will-gillis authored Dec 5, 2023
1 parent b9cb9b5 commit 2fc0c93
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 160 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/issue-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ on:
types: [opened, transferred, assigned]

jobs:
# Adds newly created issues onto project board in column 'New Issue Approval'
# Adds newly created issues onto project board in the default column 'New Issue Approval'
# unless overridden when issue has "LA website bot" in title, then 'Questions / In Review'
Add-Issue-To-Project-Board:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'issues' && github.event.action == 'opened' }}
env:
COLUMN_NAME: ${{ contains(github.event.issue.title, 'Hack for LA website bot') && 'Questions / In Review' || 'New Issue Approval' }}
steps:
- name: Add issue to project board
uses: alex-page/[email protected]
id: add-issue-project-board
uses: alex-page/[email protected]
with:
project: Project Board
column: New Issue Approval
column: ${{ env.COLUMN_NAME }}
repo-token: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }}

Add-Missing-Labels-To-Issues:
runs-on: ubuntu-latest
# Only trigger this action when an issue is newly created
Expand All @@ -25,8 +28,8 @@ jobs:
- uses: actions/checkout@v4
# Check if the issue has required labels
- name: Check Labels
uses: actions/github-script@v7
id: check-labels
uses: actions/github-script@v7
with:
script: |
const script = require('./github-actions/trigger-issue/add-missing-labels-to-issues/check-labels.js')
Expand Down Expand Up @@ -54,6 +57,7 @@ jobs:
const script = require('./github-actions/trigger-issue/add-missing-labels-to-issues/post-labels-comment.js')
script({g: github, c:context}, results)
#Asking for preliminary update when issue is assigned
Ask-For-Preliminary-update:
runs-on: ubuntu-latest
Expand All @@ -72,7 +76,6 @@ jobs:
const checklabels = script({g: github, c: context})
return checklabels
# Post the comment based on the result of the previous step
- name: Post assigning issue comment
id: assigned-comment
Expand All @@ -81,4 +84,4 @@ jobs:
script: |
const results = ${{ steps.check-labels-prelim.outputs.result }}
const script = require('./github-actions/trigger-issue/add-preliminary-comment/preliminary-update-comment.js')
script({g: github, c:context},results)
script({g: github, c:context},results)
64 changes: 59 additions & 5 deletions .github/workflows/schedule-monthly.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Schedule Monthly

# This action runs at 11:00 UTC/ 3:00 PDT on the first day of the month.
# This action runs at 11:00 UTC/ 3:00 PDT on the first day of every month except January.
on:
schedule:
- cron: 0 11 1 * *
- cron: 0 11 1 2-12 *
workflow_dispatch:

jobs:
trim_contributors:
Trim_Contributors:
runs-on: ubuntu-latest
if: github.repository == 'hackforla/website'

Expand All @@ -15,7 +16,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }}

# Setup node
- name: Setup node
Expand All @@ -29,8 +30,61 @@ jobs:
run: npm install
working-directory: ./github-actions/trigger-schedule/github-data

# Run js file- check action logs for inactive members and removes from 'website-write'
# Run js file: checks contributor activity logs, removes two-month inactive members from
# 'website-write' team, then compiles list of one-month inactive members for notification
- name: Trim Members
env:
token: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }}
run: node github-actions/trigger-schedule/github-data/contributors-data.js

# Upload artifact file to allow list sharing with next job "Create_New_Issue"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: trim_job_artifact
path: inactive-Members.json


Create_New_Issue:
needs: Trim_Contributors
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Download artifact file from "Trim_Contributors"
- name: Download artifact
id: download-artifact
uses: actions/download-artifact@v3
with:
name: trim_job_artifact

# Extract and save artifact in usable form for next steps
- name: Extract artifact
id: extract-artifact
run: |
jq -c . inactive-Members.json > out-inactive-Members.json
echo "TRIM_LISTS=$(cat out-inactive-Members.json)" >> $GITHUB_ENV
# Creates a new issue in 'hackforla/website' repo with the saved lists
- name: Create new issue
uses: actions/github-script@v7
id: create-new-issue
with:
github-token: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }}
script: |
const artifactContent = process.env.TRIM_LISTS;
const script = require('./github-actions/trigger-schedule/list-inactive-members/create-new-issue.js');
const createNewIssue = script({g: github, c: context}, artifactContent);
return createNewIssue;
# Comments on issue #2607, notifying leads that the above issue has been created
- name: Comment issue
uses: actions/github-script@v7
id: comment-issue
with:
github-token: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }}
script: |
const script = require('./github-actions/trigger-schedule/list-inactive-members/comment-issue.js');
const newIssueNumber = ${{ steps.create-new-issue.outputs.result }};
script({g: github, c: context}, newIssueNumber);
46 changes: 46 additions & 0 deletions .github/workflows/wr-schedule-monthly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: WR Schedule Monthly

on:
workflow_run:
workflows: ['Schedule Monthly']
types: [completed]

jobs:
On-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- run: echo "The 'Schedule Monthly' workflow succeeded. Continuing."

# If 'Schedule Monthly' was succcesful, retrieve the owner URL
- name: Get owner url
id: get-owner-url
uses: actions/github-script@v7
with:
script: |
const ownerURL = context.payload.repository.html_url;
console.log("Owner url: " + ownerURL);
return ownerURL;
# Then retrieve the latest issue created in the repo (i.e. by 'Schedule Monthly')
- name: Get issue number
id: get-issue-number
uses: actions/github-script@v7
with:
script: |
const newIssue = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state:"all",
per_page: 1,
page: 1,
});
const newIssueNumber = newIssue['data'][0]['number'];
console.log("Latest issue number: " + newIssueNumber);
return newIssueNumber;
# Automatically close this last issue- that is, the issue just created by 'Schedule Monthly'
- name: Auto close issue
run: gh issue close "${{ steps.get-owner-url.outputs.result }}/issues/${{ steps.get-issue-number.outputs.result }}"
env:
GH_TOKEN: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const REQUIRED_LABELS = ['Complexity', 'role', 'Feature']
const LABEL_MISSING = ['Complexity: Missing', 'role missing', 'Feature Missing']
const COMPLEXITY_EXCEPTIONS = ['good first issue']

// SPECIAL_CASE is for issue created by reference with issue title "Hack for LA website bot" (from "Review Inactive Team Members")
const SPECIAL_CASE = ['ready for dev lead','Feature: Administrative','size: 0.25pt','Complexity: Small','role: dev leads']

// Global variables
var github
var context
Expand All @@ -17,10 +20,16 @@ async function main({ g, c }) {
github = g
context = c
const issueNum = context.payload.issue.number
const issueTitle = context.payload.issue.title

const labels = obtainLabels()
const filteredLabels = filterLabels(labels)
const labelsToAdd = checkLabels(filteredLabels)
let labelsToAdd = checkLabels(filteredLabels)

// for SPECIAL_CASE noted above
if (issueTitle.includes('Hack for LA website bot')) {
labelsToAdd = SPECIAL_CASE;
}
console.log('Labels to add: ', labelsToAdd)

const result = await addLabels(labelsToAdd, filteredLabels)
Expand Down
Loading

0 comments on commit 2fc0c93

Please sign in to comment.