From ef0c665e08f1b8b5df18f83b42293a89717b2397 Mon Sep 17 00:00:00 2001 From: Kevin Deng Date: Thu, 21 May 2026 03:28:36 +0900 Subject: [PATCH] fix: evaluate static workflow expressions --- src/utils/substitute.ts | 4 ++++ tests/index.test.ts | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/utils/substitute.ts b/src/utils/substitute.ts index 7a6d51d..85a2bb3 100644 --- a/src/utils/substitute.ts +++ b/src/utils/substitute.ts @@ -54,6 +54,10 @@ export function substituteString( if (replacement !== undefined) { return replacement } + const evaluated = staticExpression(expr, values) + if (evaluated) { + return evaluated.value + } const simplified = printExpression(expr, values) const staticValue = staticExpression(parseExpression(simplified), values) return staticValue ? staticValue.value : `\${{ ${simplified} }}` diff --git a/tests/index.test.ts b/tests/index.test.ts index f0f4082..fca1a48 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -91,6 +91,21 @@ describe('actionspack', () => { ).toBe( "${{ (contains(github.ref_name, 'alpha') && 'alpha' || contains(github.ref_name, 'beta') && 'beta' || contains(github.ref_name, 'rc') && 'rc' || '') || 'latest' }}", ) + expect( + substituteValue( + { + run: "pnpm dlx pkg-pr-new@0.0 publish --pnpm ${{ inputs.compact && '--compact' || '' }} ${{ inputs.packages }} ${{ inputs['comment-package-manager'] && format('--packageManager={0}', inputs['comment-package-manager']) || '' }} ${{ inputs['comment-with-dev'] && '--commentWithDev' || '' }}", + }, + { + 'inputs.comment-package-manager': 'pnpm,npm,yarn', + 'inputs.comment-with-dev': true, + 'inputs.compact': true, + 'inputs.packages': ". './packages/*'", + }, + ), + ).toEqual({ + run: "pnpm dlx pkg-pr-new@0.0 publish --pnpm --compact . './packages/*' --packageManager=pnpm,npm,yarn --commentWithDev", + }) }) it('reports when pack has no source workflows', async () => { -- 2.51.2