From f2e640f7af2f83d2c624edb7da2c6d7d9fe7bfa3 Mon Sep 17 00:00:00 2001 From: Futa HIRAKOBA Date: Mon, 7 Oct 2024 23:10:08 +0900 Subject: [PATCH] fix: install renovate required nodejs by default --- action.yaml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/action.yaml b/action.yaml index 4fcbb12..98ec5d2 100644 --- a/action.yaml +++ b/action.yaml @@ -37,6 +37,10 @@ inputs: description: 'Renovate git author' required: false default: "GitHub Action " + install-nodejs: + description: 'if `true`, install Renovate required Node.js' + required: false + default: "true" runs: using: "composite" @@ -54,6 +58,36 @@ runs: # Create a path to save a action summary. echo "summary=${{ runner.temp }}/summary.md" >> $GITHUB_OUTPUT + # Output Renovate required node version + echo "renovate-required-node-version=$(npm view renovate --json | jq '.engines.node')" >> $GITHUB_OUTPUT + + - name: Install semver + if: inputs.install-nodejs == 'true' + shell: bash + run: npm install -g semver + + - name: Get Renovate required minimum node version + if: inputs.install-nodejs == 'true' + uses: actions/github-script@v7 + id: renovate-required-minimum-node-version + env: + RENOVATE_REQUIRED_NODE_VERSION: ${{ steps.setup.outputs.renovate-required-node-version }} + with: + result-encoding: string + script: | + const semver = require('semver'); + // get the minimum version of Node.js required by Renovate + // e.g. "semver.minVersion("^20.15.1").version" -> "20.15.1" + const minVersion = semver.minVersion(process.env.RENOVATE_REQUIRED_NODE_VERSION); + console.log(JSON.stringify(minVersion)); + return minVersion.version; + + - name: Setup Node.js + if: inputs.install-nodejs == 'true' + uses: actions/setup-node@v4 + with: + node-version: ${{ steps.renovate-required-minimum-node-version.outputs.result }} + - uses: actions/cache@v4 if: inputs.cache == 'true' with: