Skip to content

Add checkout.clean-git-credentials to support submodule-safe checkout credential cleanup#32819

Merged
pelikhan merged 29 commits into
mainfrom
copilot/fix-compiled-lock-files
May 17, 2026
Merged

Add checkout.clean-git-credentials to support submodule-safe checkout credential cleanup#32819
pelikhan merged 29 commits into
mainfrom
copilot/fix-compiled-lock-files

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 17, 2026

Compiled workflows were forcing persist-credentials: false on generated actions/checkout steps, 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

    • Generated checkout steps in agent workflows used persist-credentials: false unconditionally.
    • In submodule-heavy/sparse scenarios, checkout post-cleanup can fail with missing submodule URL/path errors.
  • Compiler/frontmatter changes

    • Added checkout.clean-git-credentials: bool to checkout config parsing/modeling.
    • Wired the flag through checkout resolution/merge logic so it can be applied per checkout target.
  • Checkout generation behavior

    • When clean-git-credentials: true:
      • emit persist-credentials: true on that checkout step
      • inject Clean git credentials after checkout immediately after the checkout
    • Cleanup step behavior:
      • prefers shared clean_git_credentials.sh from setup assets when available
      • falls back to inline cleanup logic (credential + http.*.extraheader removal)
      • scans both repo and submodule git configs (.git/config and .git/modules/*/config)
  • Credential cleaner hardening

    • Updated shared actions/setup/sh/clean_git_credentials.sh to include submodule config paths and deeper nested module traversal.
checkout:
  repository: owner/repo
  clean-git-credentials: true
- uses: actions/checkout@...
  with:
    persist-credentials: true
- name: Clean git credentials after checkout
  continue-on-error: true
  run: |
    # uses shared cleaner when available, else inline fallback

pr-sous-chef: branch update requested by run https://github.com/github/gh-aw/actions/runs/25995204443

Generated by 👨‍🍳 PR Sous Chef ·

Copilot AI and others added 2 commits May 17, 2026 13:44
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix compiled lock files to handle submodules correctly Add checkout.clean-git-credentials to support submodule-safe checkout credential cleanup May 17, 2026
Copilot AI requested a review from pelikhan May 17, 2026 13:48
Comment thread pkg/workflow/checkout_step_generator.go Outdated
Comment on lines +320 to +340
# 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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot move to helper file in actions/setup/sh

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI and others added 13 commits May 17, 2026 13:58
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 AI requested a review from pelikhan May 17, 2026 14:10
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot find an agentic workflow in the repo with a checkout field (not checkout: false) and enable this flag.

@pelikhan pelikhan marked this pull request as ready for review May 17, 2026 14:18
@github-actions
Copy link
Copy Markdown
Contributor

@copilot review all comments and address the unresolved review feedback before the next pass.

Generated by 👨‍🍳 PR Sous Chef ·

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot rename clean-git-credentials to force-clean-git-credentials

…credentials

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 17, 2026

@copilot rename clean-git-credentials to force-clean-git-credentials

Done in 2855e3d. I renamed the checkout frontmatter key to force-clean-git-credentials across parser handling, schema, tests, and updated .github/workflows/smoke-claude.md plus its recompiled lock file.

@github-actions
Copy link
Copy Markdown
Contributor

Please review the changes and address any remaining feedback.
``
@copilot review all comments

Generated by 👨‍🍳 PR Sous Chef ·

return steps
}

func generateCheckoutCredentialsCleanupStep() string {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot is this dead code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot remove the fallback, the script file is guaranteed to exist

@github-actions
Copy link
Copy Markdown
Contributor

@copilot review all comments

Please remove the fallback the maintainer called out, then rerun checks and share the result.

Generated by 👨‍🍳 PR Sous Chef ·

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 17, 2026

@copilot remove the fallback, the script file is guaranteed to exist

Implemented in ba7b0fb. I removed the generated checkout cleanup fallback and now call only bash "${RUNNER_TEMP}/gh-aw/actions/clean_git_credentials_checkout.sh".

@github-actions
Copy link
Copy Markdown
Contributor

@copilot review all comments and address any unresolved review feedback.
Then post a short blocker summary if anything still needs maintainer input.

Generated by 👨‍🍳 PR Sous Chef ·

@github-actions
Copy link
Copy Markdown
Contributor

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

@copilot merge main and recompile, then rerun the checks.
Please clear the remaining lint and gate failures so this is ready for maintainer review.

Generated by 👨‍🍳 PR Sous Chef ·

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review the changes in tbe clean git credentials shell script

Copilot AI and others added 3 commits May 17, 2026 20:46
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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 17, 2026

@copilot review the changes in tbe clean git credentials shell script

Reviewed and tightened coverage in b10b7cf. I added shell tests for .git/modules/**/config cleanup (including nested module configs), URL-scoped extraheader removal, and authenticated submodule remote URL sanitization.

@pelikhan pelikhan merged commit 95dca68 into main May 17, 2026
@pelikhan pelikhan deleted the copilot/fix-compiled-lock-files branch May 17, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiled lock files use persist-credentials: false on checkout steps — fails on repos with submodules

3 participants