diff --git a/.github/workflows/make-pr-for-release.yml b/.github/workflows/make-pr-for-release.yml index b2e22962..b1faecc2 100644 --- a/.github/workflows/make-pr-for-release.yml +++ b/.github/workflows/make-pr-for-release.yml @@ -66,16 +66,46 @@ jobs: - run: git fetch --tag + - name: Validate inputs + shell: bash + run: | + if [[ -n "$INPUT_START_FROM_GITHUB_REF" && ! "$INPUT_START_FROM_GITHUB_REF" =~ ^[a-zA-Z0-9/_.-]+$ ]]; then + echo "::error::'start-from-github-ref' input contains invalid characters. Must be a valid git ref." + exit 1 + fi + if [[ -n "$INPUT_START_FROM_NPM_DIST_TAG" && ! "$INPUT_START_FROM_NPM_DIST_TAG" =~ ^[a-zA-Z0-9_.-]+$ ]]; then + echo "::error::'start-from-npm-dist-tag' input contains invalid characters. Must be a valid npm dist-tag." + exit 1 + fi + if [[ -n "$INPUT_ONLY" && ! "$INPUT_ONLY" =~ ^[@a-zA-Z0-9/_,.-]+$ ]]; then + echo "::error::'only' input contains invalid characters. Must be a comma-separated list of package names." + exit 1 + fi + if [[ -n "$INPUT_RELEASE_CHANNEL" && ! "$INPUT_RELEASE_CHANNEL" =~ ^[a-zA-Z0-9_.-]+$ ]]; then + echo "::error::'release-channel' input contains invalid characters. Must be a valid channel name." + exit 1 + fi + env: + INPUT_START_FROM_GITHUB_REF: ${{ inputs.start-from-github-ref }} + INPUT_START_FROM_NPM_DIST_TAG: ${{ inputs.start-from-npm-dist-tag }} + INPUT_ONLY: ${{ inputs.only }} + INPUT_RELEASE_CHANNEL: ${{ inputs.release-channel }} + + # $START_FROM_GITHUB_REF_FLAG, $START_FROM_NPM_DIST_TAG_FLAG, and $ONLY_FLAG are intentionally + # unquoted — they must word-split into two args (e.g. --only ) - run: | sf-release cli:release:build \ - --release-channel "$INPUTS_RELEASE_CHANNEL" \ + --release-channel "$INPUT_RELEASE_CHANNEL" \ ${{ inputs.pinned-deps && '--pinned-deps' || '--no-pinned-deps' }} \ ${{ inputs.resolutions && '--resolutions' || '--no-resolutions' }} \ ${{ inputs.jit && '--jit' || '--no-jit' }} \ - ${{ inputs.start-from-github-ref && format('--start-from-github-ref {0}', inputs.start-from-github-ref) || '' }} \ - ${{ inputs.start-from-npm-dist-tag && format('--start-from-npm-dist-tag {0}', inputs.start-from-npm-dist-tag) || '' }} \ + $START_FROM_GITHUB_REF_FLAG \ + $START_FROM_NPM_DIST_TAG_FLAG \ ${{ inputs.patch && '--patch' || '' }} \ - ${{ inputs.only && format('--only {0}', inputs.only) || '' }} \ + $ONLY_FLAG \ ${{ inputs.empty && '--empty' || '' }} env: - INPUTS_RELEASE_CHANNEL: ${{ inputs.release-channel }} + INPUT_RELEASE_CHANNEL: ${{ inputs.release-channel }} + START_FROM_GITHUB_REF_FLAG: ${{ inputs.start-from-github-ref && format('--start-from-github-ref {0}', inputs.start-from-github-ref) || '' }} + START_FROM_NPM_DIST_TAG_FLAG: ${{ inputs.start-from-npm-dist-tag && format('--start-from-npm-dist-tag {0}', inputs.start-from-npm-dist-tag) || '' }} + ONLY_FLAG: ${{ inputs.only && format('--only {0}', inputs.only) || '' }}