Skip to content

Commit

Permalink
cleanup authentication config at the end of action
Browse files Browse the repository at this point in the history
Part of: NSL-3391
  • Loading branch information
gmichelo committed Jun 4, 2024
1 parent e9d8ebd commit 1d33a43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ export async function run(): Promise<void> {
`git --git-dir ${repoDir}/.git --work-tree ${repoDir} checkout --progress --force ${commit}`
)
}

// Cleanup authentication config
await cleanupGitAuth()
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)
Expand Down Expand Up @@ -287,6 +290,19 @@ async function configGitAuth(token: string) {
)
}

async function cleanupGitAuth() {
await exec.exec(
`git config --global --unset-all http.https://github.com/.extraheader`,
[],
{ ignoreReturnCode: true }
)
await exec.exec(
`git config --global --unset-all url.https://github.com/.insteadOf`,
[],
{ ignoreReturnCode: true }
)
}

async function gitClone(
owner: string,
repo: string,
Expand Down

0 comments on commit 1d33a43

Please sign in to comment.