Merge pull request #213 from iloveitaly/sync-git-config

fix: execute git config commands synchronously
releases/v3
Tycho Bokdam 2023-05-18 15:16:11 +02:00 committed by GitHub
commit d479ae227c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View File

@ -14,10 +14,6 @@ module.exports = new (class Git {
// Make the Github token secret // Make the Github token secret
core.setSecret(githubToken) core.setSecret(githubToken)
const gitUserName = core.getInput('git-user-name')
const gitUserEmail = core.getInput('git-user-email')
const gitUrl = core.getInput('git-url')
// if the env is dont-use-git then we mock exec as we are testing a workflow // if the env is dont-use-git then we mock exec as we are testing a workflow
if (ENV === 'dont-use-git') { if (ENV === 'dont-use-git') {
this.exec = (command) => { this.exec = (command) => {
@ -30,14 +26,21 @@ module.exports = new (class Git {
} }
} }
} }
}
init = async () => {
const gitUserName = core.getInput('git-user-name')
const gitUserEmail = core.getInput('git-user-email')
const gitUrl = core.getInput('git-url')
const githubToken = core.getInput('github-token')
// Set config // Set config
this.config('user.name', gitUserName) await this.config('user.name', gitUserName)
this.config('user.email', gitUserEmail) await this.config('user.email', gitUserEmail)
// Update the origin // Update the origin
if (githubToken) { if (githubToken) {
this.updateOrigin(`https://x-access-token:${githubToken}@${gitUrl}/${GITHUB_REPOSITORY}.git`) await this.updateOrigin(`https://x-access-token:${githubToken}@${gitUrl}/${GITHUB_REPOSITORY}.git`)
} }
} }

View File

@ -79,6 +79,8 @@ async function run() {
core.info(`Skipping empty releases is "${skipEmptyRelease ? 'enabled' : 'disabled'}"`) core.info(`Skipping empty releases is "${skipEmptyRelease ? 'enabled' : 'disabled'}"`)
core.info(`Skipping the update of the version file is "${skipVersionFile ? 'enabled' : 'disabled'}"`) core.info(`Skipping the update of the version file is "${skipVersionFile ? 'enabled' : 'disabled'}"`)
await git.init()
if (!skipGitPull) { if (!skipGitPull) {
core.info('Pull to make sure we have the full git history') core.info('Pull to make sure we have the full git history')
await git.pull() await git.pull()