Add checkout.clean-git-credentials to support submodule-safe checkout credential cleanup#32819
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
checkout.clean-git-credentials to support submodule-safe checkout credential cleanup
| # The shared cleaner script is available only after Setup Scripts has copied | ||
| # actions into ${RUNNER_TEMP}/gh-aw/actions. This checkout-time step may run | ||
| # earlier, so keep an inline fallback for pre-setup execution. | ||
| if [ -x "${RUNNER_TEMP}/gh-aw/actions/clean_git_credentials.sh" ]; then | ||
| echo "Using shared clean_git_credentials.sh from setup action" | ||
| bash "${RUNNER_TEMP}/gh-aw/actions/clean_git_credentials.sh" | ||
| exit 0 | ||
| fi | ||
| echo "Shared clean_git_credentials.sh not available yet; using inline fallback" | ||
| cleaned=0 | ||
| while IFS= read -r git_config; do | ||
| git config --file "${git_config}" --remove-section credential 2>/dev/null || true | ||
| git config --file "${git_config}" --unset-all http.extraheader 2>/dev/null || true | ||
| git config --file "${git_config}" --get-regexp '^http\..*\.extraheader$' 2>/dev/null | while read -r key _; do | ||
| git config --file "${git_config}" --unset-all "${key}" || true | ||
| done || true | ||
| cleaned=$((cleaned + 1)) | ||
| done < <(find "${GITHUB_WORKSPACE}" /tmp -maxdepth 15 -type f -name "config" \( -path "*/.git/config" -o -path "*/.git/modules/*/config" \) 2>/dev/null | sort -u) | ||
| if [ "${cleaned}" -eq 0 ]; then | ||
| echo "No git config files found for cleanup" | ||
| fi |
There was a problem hiding this comment.
@copilot move to helper file in actions/setup/sh
There was a problem hiding this comment.
Done in 65317ac. I moved the checkout-time fallback cleanup logic out of checkout_step_generator.go into actions/setup/sh/clean_git_credentials_pre_setup.sh and updated the generated checkout cleanup step to use helper script paths.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot find an agentic workflow in the repo with a checkout field (not checkout: false) and enable this flag. |
|
|
|
@copilot rename clean-git-credentials to |
…credentials Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Please review the changes and address any remaining feedback.
|
| return steps | ||
| } | ||
|
|
||
| func generateCheckoutCredentialsCleanupStep() string { |
There was a problem hiding this comment.
No — it’s an intentional fallback path, not dead code. The primary path is ${RUNNER_TEMP}/gh-aw/actions/clean_git_credentials_checkout.sh, and this inline branch is only for cases where that helper is missing at runtime (for example setup assets not present).
|
@copilot remove the fallback, the script file is guaranteed to exist |
|
Please remove the fallback the maintainer called out, then rerun checks and share the result.
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
|
|
Caution agentic threat detected DetailsPotential security threats were detected in the agent output. Review the workflow run logs for details.
|
|
@copilot review the changes in tbe clean git credentials shell script |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Compiled workflows were forcing
persist-credentials: falseon generatedactions/checkoutsteps, which breaks on repositories with submodules during checkout post-step cleanup. This change adds an explicit frontmatter mode to keep credentials persisted for checkout while still cleaning git credentials in a submodule-compatible way.Problem scope
persist-credentials: falseunconditionally.Compiler/frontmatter changes
checkout.clean-git-credentials: boolto checkout config parsing/modeling.Checkout generation behavior
clean-git-credentials: true:persist-credentials: trueon that checkout stepClean git credentials after checkoutimmediately after the checkoutclean_git_credentials.shfrom setup assets when availablehttp.*.extraheaderremoval).git/configand.git/modules/*/config)Credential cleaner hardening
actions/setup/sh/clean_git_credentials.shto include submodule config paths and deeper nested module traversal.pr-sous-chef: branch update requested by run https://github.com/github/gh-aw/actions/runs/25995204443