diff --git a/.github/workflows/sync-audit-logs.yml b/.github/workflows/sync-audit-logs.yml index 180a0183a0..d2e938bd45 100644 --- a/.github/workflows/sync-audit-logs.yml +++ b/.github/workflows/sync-audit-logs.yml @@ -33,7 +33,7 @@ jobs: # need to use a token from a user with access to github/audit-log-allowlists for this step GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WRITEORG_PROJECT }} run: | - src/audit-logs/scripts/sync.js + npm run audit-log-sync - name: Get the audit-log-allowlists SHA being synced id: audit-log-allowlists diff --git a/package.json b/package.json index a0ebcb6fb5..778b3ee3f6 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "scripts": { "analyze-text": "node src/search/scripts/analyze-text.js", "archive-version": "node --max-old-space-size=8192 src/ghes-releases/scripts/archive-version.js", + "audit-log-sync": "tsx src/audit-logs/scripts/sync.ts", "build": "next build", "check-content-type": "node src/workflows/check-content-type.js", "check-github-github-links": "node src/links/scripts/check-github-github-links.js", diff --git a/src/audit-logs/README.md b/src/audit-logs/README.md index 4b110706b1..7fbe98ee96 100644 --- a/src/audit-logs/README.md +++ b/src/audit-logs/README.md @@ -34,13 +34,13 @@ A [workflow](.github/workflows/sync-audit-logs.yml) is used to trigger the autom The workflow creates a pull request with audit log event updates and the label `audit-log-pipeline`. If there is no updated audit log data, a pull request is not created. -The workflow runs the `src/audit-logs/scripts/sync.js` script. +The workflow runs the `src/audit-logs/scripts/sync.ts` script. ## Local development To run the audit log events pipeline locally: -1. Run `src/audit-logs/scripts/sync.js` +1. Run `npm run audit-log-sync` ## About this directory @@ -48,7 +48,7 @@ To run the audit log events pipeline locally: - `src/audit-logs/lib` - The source code used in production to display the audit log event docs and configuration files edited by content and engineering team members. - `src/audit-logs/lib/config.json` - A configuration file used to specify metadata about the audit logs pipeline. - `src/audit-logs/scripts` - The scripts and source code used run the audit logs pipeline, which updates the `src/audit-logs/data` directory. - - `src/audit-logs/scripts/sync.js` - The script that runs the audit-logs pipeline. + - `src/audit-logs/scripts/sync.ts` - The script that runs the audit-logs pipeline. - `src/audit-logs/tests` - The tests used to verify the audit logs pipeline. ## Content team diff --git a/src/audit-logs/scripts/sync.js b/src/audit-logs/scripts/sync.ts similarity index 92% rename from src/audit-logs/scripts/sync.js rename to src/audit-logs/scripts/sync.ts index 6f682de255..cad51b556c 100755 --- a/src/audit-logs/scripts/sync.js +++ b/src/audit-logs/scripts/sync.ts @@ -15,12 +15,12 @@ import { mkdirp } from 'mkdirp' import path from 'path' import { filterByAllowlistValues, filterAndUpdateGhesDataByAllowlistValues } from '../lib/index.js' -import { getContents, getCommitSha } from '#src/workflows/git-utils.js' +import { getContents, getCommitSha } from '@/workflows/git-utils.js' import { latest, latestStable, releaseCandidate, -} from '#src/versions/lib/enterprise-server-releases.js' +} from '@/versions/lib/enterprise-server-releases.js' if (!process.env.GITHUB_TOKEN) { throw new Error('GITHUB_TOKEN environment variable must be set to run this script') @@ -34,6 +34,13 @@ const AUDIT_LOG_PAGES = { ENTERPRISE: 'enterprise', } +type AuditLogEventT = { + action: string + description: string +} + +type AuditLogdata = Record> + async function main() { // get latest audit log data // @@ -75,14 +82,19 @@ async function main() { // data for every supported GHES version including RC releases. Just to be // extra careful, we also fallback to the latest stable GHES version if // there's an RC release in the docs site but no audit log data for that version. - const auditLogData = {} + const auditLogData: Record = {} + // Wrapper around filterByAllowlistValues() because we always need all the // schema events and pipeline config data. - const filter = (allowListValues, currentEvents = []) => + const filter = (allowListValues: string | string[], currentEvents: AuditLogEventT[] = []) => filterByAllowlistValues(schemaEvents, allowListValues, currentEvents, pipelineConfig) // Wrapper around filterGhesByAllowlistValues() because we always need all the // schema events and pipeline config data. - const filterAndUpdateGhes = (allowListValues, auditLogPage, currentEvents) => + const filterAndUpdateGhes = ( + allowListValues: string | string[], + auditLogPage: string, + currentEvents: AuditLogdata, + ) => filterAndUpdateGhesDataByAllowlistValues( schemaEvents, allowListValues,