From 99f4f9a7263d17ff6bf08719331f6222f3202a43 Mon Sep 17 00:00:00 2001 From: Nathan Totten Date: Mon, 13 Nov 2023 19:59:16 -0500 Subject: [PATCH] update api rating result to storage --- .github/workflows/apis-guru.yaml | 27 ++++++++++----------------- apps/api/apis-guru.mjs | 11 +++++------ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/workflows/apis-guru.yaml b/.github/workflows/apis-guru.yaml index bb1d356..7c75d6f 100644 --- a/.github/workflows/apis-guru.yaml +++ b/.github/workflows/apis-guru.yaml @@ -1,8 +1,8 @@ name: APIs Guru Ratings on: workflow_dispatch: - # schedule: - # - cron: "0 17,22 * * 1-5" + schedule: + - cron: 0 0 * * 0 jobs: generate: @@ -15,14 +15,6 @@ jobs: steps: - uses: actions/checkout@v4 - with: - ref: main - token: ${{ secrets.GH_TOKEN_COMMIT_AND_BYPASS_BRANCH_PROTECTION }} - - - name: Setup Git - run: | - git config user.name "Integration Service" - git config user.email "" - id: "auth-gcp" name: "Authenticate to Google Cloud" @@ -53,10 +45,11 @@ jobs: GOOGLE_CLOUD_PROJECT_ID: zuplo-marketing OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - - name: git add changed files - run: git add apis-guru.json - - - name: Commit Updated API Ratings - run: | - git commit -m "Updated API Ratings" - git push origin main + - name: Upload Package.json + uses: "google-github-actions/upload-cloud-storage@v1" + with: + path: apis-guru.json + destination: rate-my-openapi-public + parent: false + headers: |- + content-type: application/json diff --git a/apps/api/apis-guru.mjs b/apps/api/apis-guru.mjs index dac925b..e81a21f 100644 --- a/apps/api/apis-guru.mjs +++ b/apps/api/apis-guru.mjs @@ -31,17 +31,17 @@ await fs.promises.writeFile(ratingsPath, reportJson, "utf-8"); async function rateFile(file) { console.log(`Processing ${file}`); + const relativeFile = path.relative(baseDir, file); const { stdout } = await execa( "git", - ["log", "-1", "--format=%ad", "--", path.relative(baseDir, file)], + ["log", "-1", "--format=%ad", "--", relativeFile], { cwd: baseDir }, ); const lastModified = new Date(stdout); - const report = - ratings.find((r) => r.file === path.relative(baseDir, file)) || {}; + const report = ratings.find((r) => r.file === relativeFile) || {}; if ( report.lastModified ? new Date(report.lastModified) >= lastModified : false ) { @@ -53,11 +53,10 @@ async function rateFile(file) { await createReportFromLocal(file, reportId); - report.file = path.relative(baseDir, file); + report.file = relativeFile; report.lastModified = lastModified.toISOString(); report.reportId = reportId; ratings.push(report); - - console.log({ reportId }); + console.log(report); }