-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Refactor Github Action per b/485167538 #19373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,5 +18,7 @@ runs: | |
| shell: 'bash' | ||
| run: |- | ||
| echo ""@google-gemini:registry=https://npm.pkg.github.com"" > ~/.npmrc | ||
| echo ""//npm.pkg.github.com/:_authToken=${{ inputs.github-token }}"" >> ~/.npmrc | ||
| echo ""//npm.pkg.github.com/:_authToken=${INPUTS_GITHUB_TOKEN}"" >> ~/.npmrc | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using printf "//npm.pkg.github.com/:_authToken=%s\n" "$INPUTS_GITHUB_TOKEN" >> ~/.npmrc |
||
| echo ""@google:registry=https://wombat-dressing-room.appspot.com"" >> ~/.npmrc | ||
| env: | ||
| INPUTS_GITHUB_TOKEN: ${{ inputs.github-token }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,10 +71,13 @@ runs: | |
| ${{ inputs.dry-run != 'true' }} | ||
| env: | ||
| NODE_AUTH_TOKEN: '${{ steps.core-token.outputs.auth-token }}' | ||
| INPUTS_CORE_PACKAGE_NAME: ${{ inputs.core-package-name }} | ||
| INPUTS_VERSION: ${{ inputs.version }} | ||
| INPUTS_CHANNEL: ${{ inputs.channel }} | ||
| shell: 'bash' | ||
| working-directory: '${{ inputs.working-directory }}' | ||
| run: | | ||
| npm dist-tag add ${{ inputs.core-package-name }}@${{ inputs.version }} ${{ inputs.channel }} | ||
| npm dist-tag add ${INPUTS_CORE_PACKAGE_NAME}@${INPUTS_VERSION} ${INPUTS_CHANNEL} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The environment variables are used without quotes. This can lead to word splitting and globbing by the shell, and potentially command injection if the variables contain special characters. It's a security best practice to always quote variables in shell scripts. npm dist-tag add "${INPUTS_CORE_PACKAGE_NAME}@${INPUTS_VERSION}" "${INPUTS_CHANNEL}" |
||
|
|
||
| - name: 'Get cli Token' | ||
| uses: './.github/actions/npm-auth-token' | ||
|
|
@@ -91,10 +94,13 @@ runs: | |
| ${{ inputs.dry-run != 'true' }} | ||
| env: | ||
| NODE_AUTH_TOKEN: '${{ steps.cli-token.outputs.auth-token }}' | ||
| INPUTS_CLI_PACKAGE_NAME: ${{ inputs.cli-package-name }} | ||
| INPUTS_VERSION: ${{ inputs.version }} | ||
| INPUTS_CHANNEL: ${{ inputs.channel }} | ||
| shell: 'bash' | ||
| working-directory: '${{ inputs.working-directory }}' | ||
| run: | | ||
| npm dist-tag add ${{ inputs.cli-package-name }}@${{ inputs.version }} ${{ inputs.channel }} | ||
| npm dist-tag add ${INPUTS_CLI_PACKAGE_NAME}@${INPUTS_VERSION} ${INPUTS_CHANNEL} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The environment variables are used without quotes. This can lead to word splitting and globbing by the shell, and potentially command injection if the variables contain special characters. It's a security best practice to always quote variables in shell scripts. npm dist-tag add "${INPUTS_CLI_PACKAGE_NAME}@${INPUTS_VERSION}" "${INPUTS_CHANNEL}" |
||
|
|
||
| - name: 'Get a2a Token' | ||
| uses: './.github/actions/npm-auth-token' | ||
|
|
@@ -111,15 +117,29 @@ runs: | |
| ${{ inputs.dry-run == 'false' }} | ||
| env: | ||
| NODE_AUTH_TOKEN: '${{ steps.a2a-token.outputs.auth-token }}' | ||
| INPUTS_A2A_PACKAGE_NAME: ${{ inputs.a2a-package-name }} | ||
| INPUTS_VERSION: ${{ inputs.version }} | ||
| INPUTS_CHANNEL: ${{ inputs.channel }} | ||
| shell: 'bash' | ||
| working-directory: '${{ inputs.working-directory }}' | ||
| run: | | ||
| npm dist-tag add ${{ inputs.a2a-package-name }}@${{ inputs.version }} ${{ inputs.channel }} | ||
| npm dist-tag add ${INPUTS_A2A_PACKAGE_NAME}@${INPUTS_VERSION} ${INPUTS_CHANNEL} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The environment variables are used without quotes. This can lead to word splitting and globbing by the shell, and potentially command injection if the variables contain special characters. It's a security best practice to always quote variables in shell scripts. npm dist-tag add "${INPUTS_A2A_PACKAGE_NAME}@${INPUTS_VERSION}" "${INPUTS_CHANNEL}" |
||
|
|
||
| - name: 'Log dry run' | ||
| if: |- | ||
| ${{ inputs.dry-run == 'true' }} | ||
| shell: 'bash' | ||
| working-directory: '${{ inputs.working-directory }}' | ||
| run: | | ||
| echo "Dry run: Would have added tag '${{ inputs.channel }}' to version '${{ inputs.version }}' for ${{ inputs.cli-package-name }}, ${{ inputs.core-package-name }}, and ${{ inputs.a2a-package-name }}." | ||
| echo "Dry run: Would have added tag '${INPUTS_CHANNEL}' to version '${INPUTS_VERSION}' for ${INPUTS_CLI_PACKAGE_NAME}, ${INPUTS_CORE_PACKAGE_NAME}, and ${INPUTS_A2A_PACKAGE_NAME}." | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The package name variables are unquoted in this echo "Dry run: Would have added tag '${INPUTS_CHANNEL}' to version '${INPUTS_VERSION}' for '${INPUTS_CLI_PACKAGE_NAME}', '${INPUTS_CORE_PACKAGE_NAME}', and '${INPUTS_A2A_PACKAGE_NAME}'." |
||
|
|
||
| env: | ||
| INPUTS_CHANNEL: ${{ inputs.channel }} | ||
|
|
||
| INPUTS_VERSION: ${{ inputs.version }} | ||
|
|
||
| INPUTS_CLI_PACKAGE_NAME: ${{ inputs.cli-package-name }} | ||
|
|
||
| INPUTS_CORE_PACKAGE_NAME: ${{ inputs.core-package-name }} | ||
|
|
||
| INPUTS_A2A_PACKAGE_NAME: ${{ inputs.a2a-package-name }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,10 +64,13 @@ runs: | |
| working-directory: '${{ inputs.working-directory }}' | ||
| run: |- | ||
| gemini_version=$(gemini --version) | ||
| if [ "$gemini_version" != "${{ inputs.expected-version }}" ]; then | ||
| echo "❌ NPM Version mismatch: Got $gemini_version from ${{ inputs.npm-package }}, expected ${{ inputs.expected-version }}" | ||
| if [ "$gemini_version" != "${INPUTS_EXPECTED_VERSION}" ]; then | ||
| echo "❌ NPM Version mismatch: Got $gemini_version from ${INPUTS_NPM_PACKAGE}, expected ${INPUTS_EXPECTED_VERSION}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variables in this echo "❌ NPM Version mismatch: Got '$gemini_version' from '${INPUTS_NPM_PACKAGE}', expected '${INPUTS_EXPECTED_VERSION}'" |
||
| exit 1 | ||
| fi | ||
| env: | ||
| INPUTS_EXPECTED_VERSION: ${{ inputs.expected-version }} | ||
| INPUTS_NPM_PACKAGE: ${{ inputs.npm-package }} | ||
|
|
||
| - name: 'Clear npm cache' | ||
| shell: 'bash' | ||
|
|
@@ -77,11 +80,14 @@ runs: | |
| shell: 'bash' | ||
| working-directory: '${{ inputs.working-directory }}' | ||
| run: |- | ||
| gemini_version=$(npx --prefer-online "${{ inputs.npm-package}}" --version) | ||
| if [ "$gemini_version" != "${{ inputs.expected-version }}" ]; then | ||
| echo "❌ NPX Run Version mismatch: Got $gemini_version from ${{ inputs.npm-package }}, expected ${{ inputs.expected-version }}" | ||
| gemini_version=$(npx --prefer-online "${INPUTS_NPM_PACKAGE}" --version) | ||
| if [ "$gemini_version" != "${INPUTS_EXPECTED_VERSION}" ]; then | ||
| echo "❌ NPX Run Version mismatch: Got $gemini_version from ${INPUTS_NPM_PACKAGE}, expected ${INPUTS_EXPECTED_VERSION}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variables in this echo "❌ NPX Run Version mismatch: Got '$gemini_version' from '${INPUTS_NPM_PACKAGE}', expected '${INPUTS_EXPECTED_VERSION}'" |
||
| exit 1 | ||
| fi | ||
| env: | ||
| INPUTS_NPM_PACKAGE: ${{ inputs.npm-package }} | ||
| INPUTS_EXPECTED_VERSION: ${{ inputs.expected-version }} | ||
|
|
||
| - name: 'Install dependencies for integration tests' | ||
| shell: 'bash' | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactoring is incomplete. The
runscript still contains a GitHub Actions expression that depends on an input (inputs.npm-tag). To complete the security hardening and improve readability, this logic should be moved into the shell script itself, using an environment variable for the input.I recommend adding
INPUTS_NPM_TAG: ${{ inputs.npm-tag }}to theenvblock for this step and then modifying therunscript to handle the logic in bash: