Fix GitHub Actions expression evaluation error in build workflow (#12884) (#12901)

* Fix GitHub Actions expression evaluation error in build workflow

- Add hcp-setup job with explicit step-by-step parameter validation
- Replace problematic inline expressions with debuggable logic steps
- Use proper fallback values (0 instead of '') for number type inputs
- Resolve 'Unexpected value' error on scheduled runs
- Maintain existing workflow logic and conditional behavior
- Add clear logging for troubleshooting parameter resolution

* Fix type conversion for pull-request number in build workflow

- Use fromJSON() to convert string output to number type
- Resolves type mismatch error in reusable workflow input

Co-authored-by: Luis (LT) Carbonell <lt.carbonell@hashicorp.com>
This commit is contained in:
Vault Automation 2026-03-10 17:04:36 -04:00 committed by GitHub
parent 8b3ebfc1fe
commit 383e2267ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -392,6 +392,44 @@ jobs:
web-ui-cache-key: ${{ needs.ui.outputs.cache-key }}
secrets: inherit
# Setup HCP input parameters with proper validation
hcp-setup:
runs-on: ubuntu-latest
outputs:
pull-request-number: ${{ steps.pr-logic.outputs.pull-request-number }}
branch-name: ${{ steps.branch-logic.outputs.branch-name }}
steps:
- id: pr-logic
name: Determine pull request number
run: |
echo "Analyzing PR context for event: ${{ github.event_name }}"
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
PR_NUM="${{ github.event.pull_request.number }}"
if [[ -n "$PR_NUM" && "$PR_NUM" != "null" ]]; then
echo "PR context detected, using number: $PR_NUM"
else
echo "PR context but no valid number found, using 0"
PR_NUM="0"
fi
else
PR_NUM="0"
echo "Non-PR context, using fallback value: $PR_NUM"
fi
echo "pull-request-number=$PR_NUM" >> "$GITHUB_OUTPUT"
- id: branch-logic
name: Determine branch name
run: |
echo "Analyzing branch context for event: ${{ github.event_name }}"
if [[ "${{ github.event_name }}" == "schedule" ]]; then
BRANCH="main"
echo "Schedule context, using branch: $BRANCH"
else
BRANCH=""
echo "Non-schedule context, using empty branch"
fi
echo "branch-name=$BRANCH" >> "$GITHUB_OUTPUT"
hcp-image:
# Logic: Run HCP image job if:
# if needs.setup.outputs.is-ent-branch != 'true' then
@ -418,10 +456,11 @@ jobs:
needs:
- setup
- artifacts-ent
- hcp-setup
uses: ./.github/workflows/build-hcp-image.yml
with:
pull-request: ${{ github.event_name == 'pull_request' && github.event.pull_request && github.event.pull_request.number || '' }}
branch: ${{ github.event_name == 'schedule' && 'main' || '' }}
pull-request: ${{ fromJSON(needs.hcp-setup.outputs.pull-request-number) }}
branch: ${{ needs.hcp-setup.outputs.branch-name }}
create-aws-image: true
create-azure-image: false
hcp-environment: int