From aa24b1a6e16fa2f5ba9d845ee0fdd9c7868d18de Mon Sep 17 00:00:00 2001 From: Marcus Weiner Date: Sun, 23 Jul 2023 15:50:28 +0200 Subject: [PATCH] Parse renovate log output --- .github/workflows/renovate-test.yml | 38 ++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/renovate-test.yml b/.github/workflows/renovate-test.yml index d8285e2..6f1a762 100644 --- a/.github/workflows/renovate-test.yml +++ b/.github/workflows/renovate-test.yml @@ -13,6 +13,7 @@ jobs: uses: renovatebot/github-action@v39.0.1 with: token: ${{ secrets.GITHUB_TOKEN }} + env-regex: "^(?:RENOVATE_\\w+|LOG_LEVEL|LOG_FORMAT)$" env: RENOVATE_DRY_RUN: lookup RENOVATE_USERNAME: renovate-bot @@ -20,4 +21,39 @@ jobs: RENOVATE_REPOSITORIES: ${{ github.repository }} RENOVATE_BASE_BRANCHES: ${{ github.ref_name }} RENOVATE_USE_BASE_BRANCH_CONFIG: merge - LOG_LEVEL: "debug" + LOG_LEVEL: debug + LOG_FORMAT: json + RENOVATE_LOG_FILE: /tmp/renovate.log + - name: Show pending updates + uses: actions/github-script@v6 + with: + script: | + const fs = require("fs/promises"); + const logFile = await fs.readFile("/tmp/renovate.log", { encoding: "utf-8" }); + const lines = logFile.split("\n"); + for (const line of lines) { + /** @type {{ msg: string, config: Record }} */ + const log = JSON.parse(line); + if (log.msg === "packageFiles with updates") { + for (const [manager, files] of Object.entries(log.config)) { + console.log(`\n--- MANAGER ${manager}`); + for (const file of files) { + console.log(`In ${file.packageFile}:`); + if (file.deps.some((d) => d.updates.length > 0)) { + for (const dep of file.deps) { + for (const update of dep.updates) { + console.log( + ` - "${dep.depName}" from ${dep.currentValue} to ${update.newVersion}` + ); + } + } + } else { + console.log(" No updates"); + } + } + } + return; + } + } + + console.log("No updates");