Skip to main content

Add GitHub Actions runs

This page shows you how to let Prism read your GitHub Actions runs.

A workflow run is one time a GitHub Actions pipeline ran. It might be a build, a test, or a release. Each run has a result: it passed, it failed, or it was cancelled.

When you finish, people can ask Prism questions like these:

  • "How many builds failed last week?"
  • "Which workflows run the most, and how long do they take?"
  • "How often did the release pipeline run this month?"

It takes about 15 minutes. You do it once.

Before you start​

You need three things.

1. You must be a Prism admin. If you can see Admin in Prism's menu, you are one.

2. A list of repositories. A repository (or "repo") is one project on GitHub. Prism reads runs only from the repositories you list. It cannot find them by itself, because GitHub has no list of every run in an organisation.

Write each repository as owner/name. The owner is your organisation's name on GitHub. For example:

my-org/payments-api

Get the list from the person who looks after your GitHub.

3. A GitHub token. A token is a password for a program. Prism uses it to read GitHub. It cannot change anything.

The token needs one permission on every repository in your list:

  • Actions: Read-only

GitHub also adds Metadata: Read-only on its own. That is expected.

The token your GitHub source already uses works, if it has Actions: Read-only. Ask the person who made it. If it doesn't have it, they can add it in GitHub. They do not need to make a new token.

Why you type the token again. Prism keeps each source's token separately. A new source cannot borrow the token from your GitHub source. So you paste it in here once more.

Step 1: Open the page​

  1. Open Prism.
  2. Click Admin.
  3. Click Context streams.

A context stream is one kind of data Prism can answer questions about.

Step 2: Choose GitHub Actions​

  1. Click Add a context stream.
  2. Find the tile called GitHub Actions.
  3. Click Use on that tile.

A form opens. Its title is Register "GitHub Actions".

Step 3: Fill in the form​

Fill in each box. Type exactly what is shown here.

name. Type:

github_actions

label. This is the name people see in answers. Type:

GitHub Actions

api_url. This is where your GitHub is.

  • If you use github.com, leave the box as it is. It already says https://api.github.com.

  • If your company runs its own GitHub server (called GitHub Enterprise Server), type its address, then /api/v3. For example, if you open GitHub at https://github.example.com, type:

    https://github.example.com/api/v3

    Use your own address, not github.example.com.

repos. Type your repositories. Put a comma between each one. For example:

my-org/payments-api, my-org/build-tools

backfill_days. This is how many days of past runs Prism reads the first time. Leave it as 30. A bigger number takes longer the first time.

max_requests_per_minute. Leave it as 60.

secret. This is the token. Paste it into this box. The box hides what you type. That is normal.

Step 4: Register​

  1. Click Register.
  2. Wait a few seconds. Prism checks the token with GitHub.

If it worked, you see GitHub Actions in the list of context streams.

If the token is wrong, you see a message, and a button that says Store the credential for github_actions. Check that you pasted the whole token. Then paste it again and click that button.

Step 5: Turn it on​

Find GitHub Actions in the list. Then:

  1. Click Approve.
  2. Click Enable.

Prism starts reading runs within 15 minutes.

Step 6: Check that it worked​

The first read takes a while. Thirty days from a few repositories usually takes 10 to 30 minutes. Wait about an hour to be safe.

Then ask Prism this question, exactly as written:

How many GitHub Actions runs were there per day over the last 14 days, and how many failed?

It worked if you get a number for each day.

To be sure, compare one day with GitHub:

  1. On GitHub, open one of your repositories.
  2. Click the Actions tab.
  3. Count the runs for one day, or ask the person who looks after GitHub.
  4. Prism's number for that repository and day should match.

It did not work if Prism says it has no data, or every day is zero. Go to "If something is wrong" below.

Changing the list of repositories later​

  1. Open Admin → Context streams and click the source.
  2. Click Edit parameters….
  3. Change repos, one owner/name per entry, separated by commas.
  4. Click Save parameters.

The source keeps its token, and stays switched on if it was on. From its next run it reads the new list. Its verification questions go back to pending, because its figures now cover a different set of repositories: ask them again once it has run.

Runs from before you add a repository are not read. Prism carries on from where it stopped. So a repository you add today has runs from about today onward. If you need its older runs, ask your technical team to set one value in the install (see the end of this page).

An answer about a period before that says so. It names the repository and the date its runs start, and it does not call the period fully covered.

How to undo it​

There are two ways.

To stop reading, but keep everything:

  1. Go to Admin, then Context streams.
  2. Find GitHub Actions.
  3. Click Disable.

Prism stops reading new runs and stops answering questions about them. The token and the settings stay. To start again, click Enable.

To remove it completely:

  1. Go to Admin, then Context streams.
  2. Find GitHub Actions.
  3. Click Delete….
  4. Type github_actions in the box.
  5. Click Delete github_actions.

This removes the source and the stored token. Nothing in GitHub changes. The runs Prism already copied stay in its database, but nobody can ask about them until you add the source again.

If something is wrong​

Prism has no runs, or every day is zero. Either the repositories had no workflow runs in the window, or the token cannot read them. To tell which:

  1. On GitHub, open one of your repositories and click the Actions tab.
  2. If it lists runs on days where Prism has none, the token is the problem. It probably doesn't have Actions: Read-only on those repositories. Ask the person who looks after GitHub to add it to the token. You do not need to type the token into Prism again. Prism picks up the change at its next read, within 6 hours.
  3. If the Actions tab lists no runs either, Prism is right: there is nothing to read. On Context streams, the stream says "The last refresh completed with 0 rows: nothing matched in what this stream reads". That is not a fault, and the stream keeps reading. Runs appear in Prism after the next read that finds some. If these repositories are not meant to run workflows, click Mark as expected to be empty on the stream. The self test then stops warning that it is empty. See Self test.

One repository is missing. Check the spelling in repos. It must be owner/name, exactly as it appears in the repository's web address.

"Store the credential" keeps failing. The token may have expired. Ask for a new one, or for the old one to be renewed.

What Prism reads, and what it does not​

  • Prism reads, for each run: the workflow's name, what started it (a push, a pull request, a schedule…), the result, who started it, and when it started and finished.
  • It does not read logs, code, secrets, or build files.
  • It reads only the repositories you list. So never read an answer as "the whole organisation".
  • Run time is clock time, from start to finish. It is not the minutes GitHub bills for.
  • A scheduled run is "started by" whoever last changed its schedule. That person did not do anything on that day.
  • Prism reads most runs only once. A run that was more than about an hour old and still going when Prism read it keeps showing as in progress, even after it finishes. So long builds can show as in progress for good. If someone re-runs an old run later, Prism does not see the re-run.

For your technical team​

  • The recipe is components/source-manifest/manifests/preview/github_actions.yaml (recipe key github_actions). It reads GET /repos/{owner}/{repo}/actions/runs, one repository at a time.
  • GitHub serves at most 1,000 runs for one date-filtered list, and says nothing when it stops. So Prism asks for two hours at a time (incremental.step: PT2H). On a test repository with 3,044 runs in one day, the busiest two hours held 333 runs, and every run landed. If a two-hour slice still holds more than 1,000 runs, Prism sees that GitHub served fewer than its total_count (total_path), splits the slice, and reads it again. A slice still short at one minute is recorded, and answers that cover it say so. A count of runs over it is a floor; a count of failed or successful runs is not, because a re-run changes a run's conclusion.
  • GitHub's own total_count for that day said 2,500, so that figure is capped too. Count by two-hour windows if you check by hand.
  • It ingests every 6 hours (schedule: PT6H). The request rate is shared with everything else using the same token: GitHub allows 5,000 requests an hour per token.
  • Older runs for a repository added later, or after the token was given more repositories: set ingest.github_actions.rewalkFrom to a date (YYYY-MM-DD) and helm upgrade. The next ingest run re-reads from that date, once. It works like ingest.github.rewalkFrom. It reaches only the stream named github_actions: a stream registered or renamed under another name is not re-read. For one stream, under any name, use Re-read from this date on its page instead (From the stream's page).