FociSolutions / github-foundations

A framework for managing your GitHub Enterprise account infrastructure.
MIT License
10 stars 1 forks source link

fix: take all of the audit logs #119

Closed bzarboni1 closed 2 months ago

bzarboni1 commented 2 months ago

ISSUE

113

After inspecting the documentation, there is a 100-entry limit to what the GH API will return, before paginating. We don't account for this, and as such only the first 100 entries will be returned.


ANALYSIS

We use a curl command to retrieve the audit logs:

curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/orgs/${{ matrix.org }}/audit-log?phrase=created:${yesterday} > audit-log-${yesterday}.json

which doesn't account for pagination. GitHub has a Javascript example / package, with which we should query:


import { Octokit } from "octokit";

const octokit = new Octokit({ });

const data = await octokit.paginate("GET /repos/{owner}/{repo}/issues", {
  owner: "octocat",
  repo: "Spoon-Knife",
  per_page: 100,
  headers: {
    "X-GitHub-Api-Version": "2022-11-28",
  },
});

console.log(data)