There are a couple of things that you need to do before you can run the code for this project. This page covers how to complete the requirements.

GitHub Personal Access Token

To access the Actions status through the GitHub API, you must have a GitHub Personal Access Token. This section will show you how to generate a new token, and how to make it available to your code.

Generate Your Personal Access Token

Visit GitHub while logged into your account. Then follow the instructions below.

The "..." in the first two images represents the middle sections of rather lengthy menus. You will need to scroll past menu items not included in the images to get to the desired menu items.
  • In the upper right corner, you'll find a small version of your avatar that is a menu. Click the dropdown menu.
  • Towards the bottom of the menu, you'll find a Settings button. Click Settings.
  • The left sidebar begins with Public Profile selected. Scroll down the page to the bottom of the sidebar. The last item in the list is Developer settings. Click Developer Settings.
  • The sidebar in Developer Settings is quite short. Click the last item in the sidebar, Personal access tokens.

Once you're on the Personal access tokens page, click Generate new token.

You may be asked to verify your access to this account via password or, if enabled, two-factor authentication. Simply verify to continue.

The New Personal Access Token page contains a couple of items for you to update.

  • Add a Note - Though not necessary, you can provide a short note as to what the token is for. This helps differentiate it from other tokens. In this case, GitHub Actions Status Light would be sufficient. Feel free to change it up to whatever works for you.
  • Verify the Expiration - The token is set to expire in 30 days by default. Depending on your needs, you can increase or decrease the expiration by clicking the dropdown menu and choosing a different expiration option, or clicking Custom... and providing an expiration date.
While it is possible to set the token to never expire, it is not recommended. The safer option is to set an expiration date, and follow the steps to add a new personal access token to your project once it expires.

The next section allows you to set specific scopes for your token. In some cases, you will need to allow certain scopes for your token to work with your project. As this project is written, a personal access token with no scope provided will work fine. Skip all the checkboxes.

At the bottom of the page, click the green Generate token button.

GitHub will generate your personal access token, return you to the Personal Access Tokens page, and display your new token for you to copy.

Copy your new personal access token immediately. This is the only time you can view the token itself. When you visit this page again, the token will no longer be displayed.
Never share your personal access tokens with others! Personal access tokens should be kept private and local to your computer at all times.

Now that your token is generated and copied to your clipboard, it's time for the next step.

Create and Update Your Token Environment Variable

Follow the steps based on which operating system you're using.

Mac OS / Linux

In the directory from which you intend to run the code, create a file called Being in the same directory as the code is not a requirement. It does, however, make it quicker to source the file when you're ready to run your code, as you'll already be in the directory containing your code.

Open the file in an editor of your choice (a text editor will be sufficient), and add the following line to the top of the file.

export GITHUB_API_TOKEN="ghp_yourtokenvaluehere"

Replace ghp_yourtokenvaluehere with your newly generated personal access token, retaining the quotation marks around it.

Save your changes to the file.

From a command line in a terminal window, run the following:


You've now made your personal access token available to the code.


Begin typing environment into the Windows search. You'll find Edit the system environment variables. Click it in the search list, and click Open to continue.

Click the New... button to open the New User Variable window. Fill in the following:

  • Variable name: = GITHUB_API_TOKEN
  • Variable value: = ghp_yourtokenvaluehere

Then click OK.

You've now made your personal access token available to the code.

You're now ready to run the code and access the GitHub API successfully!

This guide was first published on Jul 06, 2022. It was last updated on Feb 26, 2024.

This page (Code Requirements) was last updated on Jun 28, 2022.

Text editor powered by tinymce.