PyRG is a Python
implementation of the PRG framework. It is a simple Python
script that allows you to easily create a project tier table for your GitHub Portfolio. Also included is a GitHub Action CI/CD workflow that will automatically generate a table of all your repositories and their PRG tiers to deploy to GitHub Pages in order to showcase your projects/portfolio.
- Connecting Projects to the PRG framework
- Python Build Script (PyRG)
- GitHub Actions Workflow
- GitHub Pages Deployment
- Running the Workflow
- Resources
In order to get the PRG framework to work, you must perform the following pre-requisites:
- In each repository, inside the root project folder, there should be a PRG Connection File (or PRGCF for short).
- The file should be a markdown file called
PRG.md
.- See the PRG Connection File used in this repo, here, for an example and more information on how to use it.
- Follow the instructions in the file to configure your repository.
- The file name and path can be changed in the
project_tier_table_generator.py
script (default path is your project root directory).
Tip
If you do not have a specific Order to sort your repos in, use a large number like 9999 to add as a placeholder for this field, especially for Bronze projects, vs. 0 which will appear on the top of your list per tier.
Tip
You can have repeating numbers, but it should be unique by tier. For example, you can have a Order: 1
for Gold, Silver, or Bronze. Rank your repos from 1-*
for each category.
Caution
Lines 15-18 are mapped in the scripts/project_tier_table_generator.py
script to the PRG framework. Do not move or change these lines without adjusting the script to account for this change.
- The GitHub Action Workflow (explained below) uses this file to categorize your repositories.
- You must have a Repository Tier label for each repository for the categorization to work.
- Change the repository's
Tier
label to match the tier of the repository ( Platinum, Gold, Silver, Bronze, or Optimized). - The
Tier
label is the only required label for the PRG framework to work (if configured to look for a PRG Connection File file in the root folder). - Optionally, if you don't want to categorize your project, but still want to display it in your table, you can use the Optimized badge.
- There are optional labels you can add to your repository as well:
Technology
,Category
, andOrder
. - Place an empty values for
String
labels and0
forInteger
labels if you don't want to use them.
- Change the repository's
- Optionally, you can display a logo for your repository in the table. To do so, follow these steps:
- In the project root folder, there should be a folder called
docs/
. - Inside the
docs/
folder, there should be a subfolder calledimages/
. - Inside the
docs/images/
folder, there should be a file calledPRG.png
. - This is the icon that will be used for the project tier table.
- See the PRG file used in this repo, here, for an example.
- By default, if no icon is found, a placeholder image will be used (defined in the build script).
- If a homepage/website is not defined in the repository settings, clicking on the icon will link to the repository.
- Clicking on the name of the repository will always link to the repository.
- In the project root folder, there should be a folder called
Important
If you do not see your new or updated logo after you run the build script, give it a few minutes for GitHub to finish running its index process and try again.
You can view the path manually by going to https://github.com/your-username-here/your-repo-here/raw/main/docs/images/PRG.png
in your browser, which should redirect to https://raw.githubusercontent.com/your-username-here/your-repo-here/main/docs/images/PRG.png
.
You can also try a hard refresh to reset your browsers cache on the web page in order to see it.
Tip
Troubleshooting: Check that the path is correct in the project_tier_table.md
file, make sure the file is indeed in your repository docs/images
folder and its correctly named PRG.png
and that the build script is using this file name. Also, check the URL path to the file directly on GitHub to view it in a browser.
- Follow the Configuration steps below to configure the workflow and GitHub pages for deployment.
Tip
You can reference your built project tier table in your repository README
or wherever you see fit.
This can be helpful showcasing your projects using the PRG framework.
- The
python
script is located in thescripts
folder calledproject_tier_table_generator.py
.- Overall, you will see that the script is well documented, highly customizable, and easy to follow.
Warning
Make sure you add all the required fields to the private tier table in order for the table to be generated properly or this can cause the output to be incorrect.
- The build script that generates the project tier table is located in the
scripts
folder called project_tier_table_generator.py. - There are a number of configuration flags at the top of the script that you can set to customize the output of the table to your liking.
- For example, you can exclude repositories from the project tier table completely by setting the
INCLUDE_PRG_FILE_PROJECTS
flag toTrue
and not including a PRG Connection File in the root of the project.
- For example, you can exclude repositories from the project tier table completely by setting the
- The config file for Jekyll/GitHub Pages is located in the
_config.yml
file in the root of the project.- There are a number of titles and descriptions you can set to customize the output of the table to your liking.
The time zone will be updated on the bottom of the table to reflect the time zone of the repository owner and when the table was last updated.
- For local testing, adjust the
MY_TIME_ZONE
configuration in theproject_tier_table_generator.py
file. - For deployment with GitHub Pages, adjust the
TZ
environment variable underenv
to your time zone in the.github/workflows/main.yml
file.- The default time zone is set to
America/New_York
for both local testing and deployment.
- The default time zone is set to
- The script will run on a weekly basis (Monday's at 12:00 AM (Sunday Night) - defined using a cron expression in the workflow file).
- The script can also be run manually by clicking on the
Run workflow
button in theActions
tab in your repository.
If you have private/closed source or external (non-GitHub) projects, you can still use the PRG framework.
-
Private repositories that are on GitHub will be picked up if configured to do so in the script.
- Add icons for for your private repositories in the
docs/images/private_repos
folder.- For private repositories, you must name the icon the same as the repository name (case sensitive), otherwise the placeholder image will be used.
[!IMPORTANT] Even though the API can pick up private repositories, it will not be able to point to the repository URL to get the icon since it is private so you will have to manually add the icon to the
docs/images/private_repos
folder and name it the same as the repository name (case sensitive). - Add icons for for your private repositories in the
- You can manually add external projects that are not on GitHub by adding them to the
categories/project_tier_table_private.md
file.- Follow the same format as the example placeholder repository in the file.
- Add icons for for your external projects in the
docs/images/private_repos
folder (same as private repositories).- For external projects, you can name the icon whatever you want, just make sure you update the
- Projects in this file will be consolidated into the main table when the workflow runs.
You can customize your build script however you want if you want to categorize your project tier table further.
- You have three options for customizations:
- Static Table Fields:
- Feel free to add more labels/fields/columns to your project tier table.
- Be sure to adjust the
PRG.md
(PRG Connection File) and theproject_tier_table_generator.py
script accordingly. - You will also have to adjust the
project_tier_table_private.md
file to display the new fields.
- Dynamic Table Fields using GitHub API:
- There are also other API fields that can be used such as Total Stars, Forks, etc.
- If you decide to modify the output, consult the GitHub API for more details on what fields are available and be sure to adjust the
project_tier_table_generator.py
script accordingly. - You will also have to adjust the
project_tier_table_private.md
file to display the new fields.
- HTML Layouts, CSS Styles, Images and Fonts:
- Adjust the
_layouts/default.html
file to change the layout of the table. - Adjust
assets/css/style.css
to change the styling of the table. - Adjust
assets/images/
to change the images used in the table. - Adjust
assets/fonts/
to change the fonts used in the table.
- The GitHub action is defined in the
.github/workflows
folder calledmain.yml
.- The name of the workflow is
weekly-project-tier-table-generator
. - The workflow will call
scripts/project_tier_table_generator.py
which will build the table and output it tocategories/project_tier_table.md
.
- The name of the workflow is
- See the Project Tier Table and Private Project Tier Table for example inputs and outputs of what the table looks like (placeholder images won't be displayed in the output due to the GitHub Action workflow running on a public repository).
- The script will also update the Badge Reference Guide file with the latest badges you can use to add to your repository
READMEs
that use PRG.
See Badge Reference Guide for more details on how to create badges for your repository.
- Run the workflow above to get an update
categories/badge_reference_guide.md
file pointing to your PRG framework. - Place the badges in your repository
README
to showcase your PRG Collection. - Use my repos and PRG Collection as an example of how to use the badges in your
README
files.
- Build Script Testing:
- You can test the script locally by running the following command in the root of the project:
python scripts/project_tier_table_generator.py
- Jekyll Testing for GitHub Pages:
-
Install Jekyll on your machine (follow the instructions here):
gem install bundler jekyll
-
You can test the Jekyll build locally by running the following command in the root of the project:
bundle exec jekyll serve
orjekyll build
-
You can view the Jekyll build locally by going to the following URL in your browser:
http://localhost:4000/
[!NOTE] You will need to download and install both Python and Jekyll to run PRG locally.
- You will need to create a GitHub Actions API Secret in order for the workflow to run:
- Go to your GitHub profile settings.
- Click on the
Developer settings
tab. - Click on the
Personal access tokens
tab. - Click on the
Generate new token
button. - Name the token
GITHUB_TOKEN
. - Select the
repo
scope. - Click on the
Generate token
button. - Copy the token and save it somewhere safe.
- Go to your repository settings.
- Click on the
Secrets
tab. - Click on the
New repository secret
button. - Name the secret
MY_GITHUB_TOKEN
(referenced in themain.yml
file, and used as theGITHUB_TOKEN
variable in theproject_tier_table_generator.py
build script).
- Some common errors you may see when running the workflow:
Error: Resource not accessible by integration
- If you see this error, make sure you have the correct token and that you have the
repo
scope selected.
- If you see this error, make sure you have the correct token and that you have the
Error: fatal: could not read Username for 'https://github.com': terminal prompts disabled
- If your secret token is not set correctly, you will see this.
- For local testing, if you accidentally commit your token, you can revoke the token and generate a new one.
- Fork this repository.
- Go to your forked repository and click on the
Actions
tab. - Click on the
weekly-project-tier-table-generator
workflow. - Click on the
Run workflow
button. - Go to your repository settings.
- Click on the
Pages
tab. - Under
Source
, select themain
branch (or whatever branch you want to deploy from). - Click on the
Save
button. - Run the pages workflow.
- Click on the
URL
link to view your project tier table.
- The workflow should take about 1-2 minutes to run (depending on how many repositories you have).
- Be sure to add PRG Connection Files to your repositories and add the
Tier
label to each repository or else the workflow will be blank.
- Jekyll - Static Site Generator for GitHub Pages
- Jekyll Installation - Jekyll Installation Guide
- Managing a custom domain for your GitHub Pages site - GitHub Pages Custom Domain Configuration
- Troubleshooting custom domains and GitHub Pages - GitHub Pages Custom Domain Troubleshooting
- GitHub Pages: Generate SSL certificate for www subdomain - GitHub Pages SSL Certificate Generation Discussion
- Securing your GitHub Pages site with HTTPS - GitHub Pages HTTPS Configuration
- Quickstart for GitHub REST API - Learn how to get started with the GitHub REST API.
- Font Awesome - Font and Icon Toolkit used for the footer icons.