Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create JSON file and related functionality for replacing hard-coded labels #6442

Open
wants to merge 31 commits into
base: gh-pages
Choose a base branch
from

Conversation

t-will-gillis
Copy link
Member

@t-will-gillis t-will-gillis commented Mar 9, 2024

Fixes #5205

Note: OK to review however: please do not Merge yet

What changes did you make?

  • Created the JSON file with key/value pairs for all repo labels- label-directory.json and located it in a new subfolder
  • Populated the JSON file with data extracted from the HfLA repo for all label names + ids (the directory Values) and generated Key camelCased names
  • Wrote retrieve-label-directory.js that returns the actual label display name value when a label key name is provided- note that this is staging so that all GHAs can be updated
  • Wrote GHA update-label-directory.yml that is triggered whenever one of the HfLA labels is edited or is added.
  • Wrote a companion update-label-directory.js that determines whether the label is a name-change (such as by adding an emoji) or is a new label, then adds this change to the 'label directory' JSON,
  • In order to commit the changes to the repo, the GHA finishes with the stefanzweifel/[email protected]
  • Created Create new Wiki for GHA update-label-directory.yml #6968

Additionally, there are Google Apps Scripts/ Worksheets associated with this:

Why did you make the changes (we will use this info to test)?

  • This series of issues was triggered by the study of adding emoji's to issue labels.
  • We determined that we want the freedom to make changes to the labels without the need to track down all instances of each label being used. The intent of the 'label directory' is to be able to refer to a key label such as '2WeeksInactive' and return the actual label name 2 weeks inactive!!! or 💤 2 weeks inactive or however we want to change the label, however many times.

Screenshots of Proposed Changes Of The Website (if any, please do not screen shot code changes)

  • Create label: Log file from personal repo showing label creation

    Create label

    Screenshot 2024-03-10 215953

    Screenshot 2024-03-10 220157

    Screenshot 2024-03-10 220251

  • Edit label: Log file from personal repo showing label editing

    Edit label

    Screenshot 2024-03-10 220737

    Screenshot 2024-03-10 220649

    Screenshot 2024-03-10 220810

  • Delete label: Log file from personal repo showing label deletion

    Delete label

    Screenshot 2024-03-10 221255

    Notes to PR Reviewers

    • You will need to have a functioning test environment on your local repo. If you have not done this yet, see Hack for LA's GitHub Actions to set up, especially Tips 6 & 7. GHAs are quirky at first so feel free to ask questions.

    • In addition to the 'files changed' in the PR, there are additional changes that you should make to help with testing:

      • In the update-label-directory.yml file:

        • Line 11, redirect to your personal repo.
        • Line 24, the "github-token" needs to be associated with your repo.
      • Note that none of the labels in the label-directory.json file will match your repo- this is OK.

    • To test this action, you can first create a new label. Go to "Issues" in your repo***, select "New Issue", and choose "Get Started" for any of the templates. Then on the right hand side select the gear icon for "Labels", then select "Edit labels" at the bottom, and finally "New label" to the upper right. Name the issue anything you want, but it might be easier to create a label beginning with an "a", eg. A new label or whatever. "Description" and "Color" can be anything you want. Select "Create label" and confirm your label is shown on the "Labels" page.

    • (*** If you don't see "Issues" as a menu option, go to "Settings" and scroll down about halfway. Under "Features", make sure to check the box for "Issues".)

    • When you see that the label is created:

      • Confirm that GitHub Actions was triggered: select "Actions", then check that a workflow named "Update Label Directory" has run. Feel free to explore the log...
      • Confirm that your new label was added to /_data/label-directory.json. If your label starts with an "a", the JSON should be alphabetical.
    • Repeat the above steps to return to "Edit labels", select your new label, then make some change to the name. Add an emoji if you want. Confirm in that "Actions" has run and that the JSON file was updated.

    • Finally, repeat the above steps to delete the label, and confirm in "Actions" and the JSON file.

    • The tie-in can be seen here for Google Apps Script /Worksheet

Outstanding Items:

  • Done --> Add + " (deleted)" to labelName when deleted
  • Done --> Have timeline on the "Worksheet: GitHub Label Updates Log" automatically clear after certain number of days
  • Done --> Very important: Since the URL variable in the yml workflow will change every time we need to edit the Google Apps Script: We need the URL to be referenced rather than hard-coded. Should this use a doGet() call?
  • Break Google Apps Script functions into modules
  • Need "Anomaly Report" functional
  • Need a way to automatically clear deleted Label Objects from JSON after review
  • Should deleted labels be pulled into a separate object?
  • Have method/ procedure for updating keyNames hopefully without need to edit files separate, or to do a PR

@t-will-gillis t-will-gillis added this to PR Needs review (Automated Column, do not place items here manually) in Project Board via automation Mar 9, 2024
Copy link

github-actions bot commented Mar 9, 2024

Want to review this pull request? Take a look at this documentation for a step by step guide!

From your project repository, check out a new branch and test the changes.

git checkout -b t-will-gillis-create-json-label-directory-5205 gh-pages
git pull https://github.com/t-will-gillis/website.git create-json-label-directory-5205

Note that CONTRIBUTING.md cannot previewed locally; rather it should be previewed at this URL:

https://github.com/t-will-gillis/website/blob/create-json-label-directory-5205/CONTRIBUTING.md  

@github-actions github-actions bot added role: back end/devOps Tasks for back-end developers Complexity: Large time sensitive Needs to be worked on by a particular timeframe Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms size: 5pt Can be done in 19-30 hours Added to dev/pm agenda labels Mar 9, 2024
@t-will-gillis t-will-gillis added the Draft Issue is still in the process of being created label Mar 9, 2024
@github-actions github-actions bot removed the Draft Issue is still in the process of being created label Mar 10, 2024
@t-will-gillis t-will-gillis marked this pull request as draft March 12, 2024 02:31
@drakenguyen4000 drakenguyen4000 requested review from MarcosG119 and removed request for MarcosG119 March 13, 2024 02:12
@gaylem
Copy link
Member

gaylem commented Apr 15, 2024

@marioantonini I connected with Will about this issue and it looks like it's still in draft, so I'm going to remove us as reviewers for now.

Also leaving this as a note to anyone else who sees this PR and considers picking it up.

@t-will-gillis t-will-gillis added Feature: Google Apps Scripts Automation related to Google Apps Scripts size: 8pt Can be done in 31-48 hours Complexity: Extra Large Added to dev/pm agenda labels Jun 2, 2024
@t-will-gillis t-will-gillis added this to PR Needs review (Automated Column, do not place items here manually) in Project Board via automation Jun 2, 2024
Address CodeQL warning about non-declared "keyName" variable
@github-actions github-actions bot added Complexity: Large size: 5pt Can be done in 19-30 hours and removed Feature: Google Apps Scripts Automation related to Google Apps Scripts size: 8pt Can be done in 31-48 hours Complexity: Extra Large Added to dev/pm agenda labels Jun 2, 2024
@t-will-gillis t-will-gillis marked this pull request as ready for review June 6, 2024 22:40
@t-will-gillis t-will-gillis changed the title Create JSON file and related functionality for replacing hard-coded labels 5205 Create JSON file and related functionality for replacing hard-coded labels Jun 12, 2024
@mSharifHub
Copy link
Member

Hello, I am having issues testing. I added the following
`
name: Update Label Directory

on:
label:
types: [edited, created, deleted]

jobs:
Update-Label-Directory:
runs-on: ubuntu-latest
# if: github.repository == 'hackforla/website' << FIX BEFORE MERGING. FIX URL line 40 BELOW
if: github.repository == 'mSharifHub/website'
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.HFLA_PROJECT_BOARD_TOKEN }}

 - name: Dump context
   env:
     GITHUB_CONTEXT: ${{ secrets.HFLA_PROJECT_BOARD_TOKEN }}
   run: echo "GITHUB_CONTEXT defined"

 - name: Update label directory
   id: update-label-directory
   uses: actions/github-script@v7
   with:
    github-token: ${{ secrets.HFLA_PROJECT_BOARD_TOKEN }}
    script: |
      const script = require('./github-actions/utils/update-label-directory.js')
      const labelPacket = script({g: github, c: context})
      return labelPacket

 # Note the the URL below matches the *current* deployment URL of the Apps Script associated
 # with the 'Source of Truth' Label spreadsheet. (If something is broken, check this link first)
 - name: Send POST request to Google Apps Script
   if: steps.update-label-directory.outputs.result != ''
   run: |
     curl -X POST "https://script.google.com/macros/s/AKfycbyZksNnRWXB6zSJn5QwaPjHPg27NFAzZM6GSpGBb2hkgk09E68LBBZVcdQ2EUVmPjfF/exec" \
       -H "Content-Type: application/json" \
       -d '${{ steps.update-label-directory.outputs.result }}'

 # Before next step, run `git pull` so that branch is current
 - name: Pull latest changes from gh-pages
   run: git pull

 - name: Commit changes to JSON Label Directory
   uses: stefanzweifel/[email protected]
   with:
     # Glob pattern of file to commit, and opt. commit message + author
     file_pattern: github-actions/utils/_data/label-directory.json
     commit_message: Update label directory
     commit_author: GitHub Actions Bot <[email protected]>

`

I then created a label but no actions were triggered.

if you can further explain more how to test it

@t-will-gillis
Copy link
Member Author

t-will-gillis commented Jul 9, 2024

Hi @mSharifHub Thanks for the comment.

Were you able to copy the new Project Board? I see that you have a message in the Slack channel asking about an error that occurred while you were setting it up. As long as the column names copy over, you should be OK and we can deal with "PR added to project" workflow omission separately.

I am looking at your test-5205 repo and have a couple of comments:

  • I don't see that you have "Issues" enabled in your repo. If you haven't yet, go to "Settings" (last menu item at top right of your repo page), then scroll midway down and click "Issues".
  • I can't see but assuming that you created your "HFLA_PROJECT_BOARD_TOKEN"...
  • One last thing, if you have not already, you will need to change your default branch to test-5205 (if this is the correct one)

Once "Issues" is active, the automation should begin to run at least (and might fail still). Let me know if you get to this point and then we can discuss. Thanks!

@mSharifHub
Copy link
Member

Hi @mSharifHub Thanks for the comment.

Were you able to copy the new Project Board? I see that you have a message in the Slack channel asking about an error that occurred while you were setting it up. As long as the column names copy over, you should be OK and we can deal with "PR added to project" workflow omission separately.

I am looking at your test-5205 repo and have a couple of comments:

* I don't see that you have "Issues" enabled in your repo. If you haven't yet, go to "Settings" (last menu item at top right of your repo page), then scroll midway down and click "Issues".

* I can't see but assuming that you created your "HFLA_PROJECT_BOARD_TOKEN"...

* One last thing, if you have not already, you will need to change your default branch to `test-5205` (if this is the correct one)

Once "Issues" is active, the automation should begin to run at least (and might fail still). Let me know if you get to this point and then we can discuss. Thanks!

I was trying to review the PR before commenting. I have configured the token. I have created a branch from the review branch and created a label under that branch on git but did see actions being called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Large Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms role: back end/devOps Tasks for back-end developers size: 5pt Can be done in 19-30 hours time sensitive Needs to be worked on by a particular timeframe
Projects
Status: PR Needs review (Automated Column, do not place items here manually)
Project Board
  
PR Needs review (Automated Column, do...
Development

Successfully merging this pull request may close these issues.

Create JSON file and related functionality to support replacement of hard-coded issue labels
4 participants