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

Add workflow file to check alphabetical sort order of list items #1307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ClydeDz
Copy link
Contributor

@ClydeDz ClydeDz commented Jul 12, 2023

Hi,

I was working on a GitHub action that checks if the list items in a markdown file are alphabetically sorted. The idea is that every time a pull request is created with someone contributing an item to the list, a workflow will get automatically triggered which will check the markdown file in the source branch, and if it's alphabetically sorted, the action will pass. If it's not alphabetically sorted, then the action will fail and should prevent the branch from being merged. The action's console output will let the user know what are the unsorted list items from the markdown file.

I thought this repository might find this useful given the ever-growing list of amazing developer portfolios.

Summary of changes

  • Add a workflow file to check if the README.md file contents, specifically the developer portfolio list items are alphabetically sorted or not.
  • If it's not alphabetically sorted, it will throw an error with the result in the console output of the action.
  • If it's sorted as expected, it will pass.
  • This workflow will be triggered every time a pull request is made to the master branch and every time a push is made to the master branch.

How to implement it?

  1. Merge Sort developer portfolio list in alphabetical order #1306 to master so the existing portfolio list items are alphabetically sorted.
  2. Next, merge this PR which adds the workflow file to the repository.
  3. Then proceed to add branch protection rules. Click on the Add branch protection rule in the repository settings.
    image
  4. Type in master as the name of the branch to protect.
    image
  5. Scroll down to check the Require status checks to pass before merging check box. And then from the search field, type the workflow job name as pictured below, and then select it.
    image
  6. GitHub will add it to the status checks table.
    image
  7. Click on the Create button to apply these changes.

How will it look like in action?

  1. When future pull requests are opened, the workflow will run and the result will show in the PR. Picture below shows what it looks like if the item isn't sorted. Because the action has failed, the status check has also failed and thus the PR cannot be merged without fixing it.
    image
  2. If you click on Details link it will take you to the action's output. In this console, you should be able to see what items need to be ordered.
    image

Have a look at ClydeDz#3 to see this in action.

@eclectic-coding
Copy link
Collaborator

@ClydeDz this seems like a great idea. However, I do not have permissions to access the repo settings, to make the suggested Branch Protection Rules changes.

@ClydeDz
Copy link
Contributor Author

ClydeDz commented Jul 15, 2023

Thanks, @eclectic-coding! Could @emmabostian take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants