Menu

Always Set persist-credentials: false in actions/checkout
πŸ“°

Always Set persist-credentials: false in actions/checkout

DEV Community: cicdΒ·Abhinav YadavΒ·16 days ago
#Da8sNzid
#devtocicd#devto#dev#credentials#github
Reading 0:00
15s threshold

There's a default in actions/checkout\ that most teams never change β€” and that quietly leaves a GitHub token sitting in a readable file for every subsequent step in the job.

The fix is one line. The reasoning is worth understanding.

The Setting

- uses : actions/checkout@v4 with : persist-credentials : false # default is true ~~~

By default (\`persist-credentials : true \`), the checkout action writes a git credential config file containing your GitHub token to \`$RUNNER_TEMP\`. That file persists for the lifetime of the job.

## What the File Looks Like

The checkout action creates a file at \`$RUNNER_TEMP/git-credentials-<UUID>.config\`:

~~~ini [ http "https : //github.com/" ] extraheader = AUTHORIZATION : basic <Base64-encoded-string> ~~~

The Base64 string decodes to \`x-access-token:<GITHUB_TOKEN>\`. It's not encrypted. It's not write-protected.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.