diff --git a/README.md b/README.md index e966fc5..1e9d170 100644 --- a/README.md +++ b/README.md @@ -40,12 +40,6 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/ # # Default: ${{ github.token }} token: '' - - # Github slug used to configure local user.name and user.email for git. - # This is required to push a commit from a Github Action Workflow - # Set to '' to disable this configuration - # Default: "github-action[bot] - git-config: '' # SSH key used to fetch the repository. The SSH key is configured with the local # git config, which enables your scripts to run authenticated git commands. The diff --git a/action.yml b/action.yml index d1a2902..2e37912 100644 --- a/action.yml +++ b/action.yml @@ -22,12 +22,12 @@ inputs: [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets) default: ${{ github.token }} - git-user: + configure-user: description: > - Github slug used to configure local user.name and user.email for git. + Whether to configure user.name and user.email in the local git config. This is required to push a commit from a Github Action Workflow. - Set to '' to disable this configuration. - default: "github-action[bot]" + Set to `false` to disable the config. + default: true ssh-key: description: > SSH key used to fetch the repository. The SSH key is configured with the local diff --git a/dist/index.js b/dist/index.js index b5e352a..230e725 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1814,7 +1814,8 @@ function getInputs() { // Auth token result.authToken = core.getInput('token', { required: true }); // Configure user - result.gitUser = (core.getInput('git-user') || 'github-action[bot]') + result.configureUser = + (core.getInput('configure-user') || 'true').toUpperCase() === 'TRUE' // SSH result.sshKey = core.getInput('ssh-key'); result.sshKnownHosts = core.getInput('ssh-known-hosts'); diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index bb4c5a5..dcdb9b2 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -274,14 +274,12 @@ export async function getSource(settings: IGitSourceSettings): Promise { settings.commit, settings.githubServerUrl ) - if (settings.gitUser) { + if (settings.configureUser) { if (!await git.configExists('user.name', true)) { - await git.config('user.name', settings.gitUser, true) + await git.config('user.name', 'github-action[bot]', true) } if (!await git.configExists('user.email', true)) { - - const userId = await githubApiHelper.getUserId(settings.gitUser, settings.authToken, settings.githubServerUrl); - await git.config('user.email', `${userId}+${settings.gitUser}@users.noreply.github.com`, true) + await git.config('user.email', '41898282+github-actions[bot]@users.noreply.github.com', true) } } } finally { diff --git a/src/git-source-settings.ts b/src/git-source-settings.ts index 9cc2919..e7ddb41 100644 --- a/src/git-source-settings.ts +++ b/src/git-source-settings.ts @@ -80,9 +80,9 @@ export interface IGitSourceSettings { authToken: string /** - * A github user slug to set a default user name and email in the local git config + * Indicates whether to set a default user name and email in the local git config */ - gitUser: string + configureUser: boolean /** * The SSH key to configure diff --git a/src/github-api-helper.ts b/src/github-api-helper.ts index b90b990..1ff27c2 100644 --- a/src/github-api-helper.ts +++ b/src/github-api-helper.ts @@ -143,15 +143,3 @@ async function downloadArchive( }) return Buffer.from(response.data as ArrayBuffer) // response.data is ArrayBuffer } - -export async function getUserId( - username: string, - authToken: string, - baseUrl?: string -): Promise { - const octokit = github.getOctokit(authToken, { - baseUrl: getServerApiUrl(baseUrl) - }) - const user = await octokit.rest.users.getByUsername({username,}); - return user.data.id -} diff --git a/src/input-helper.ts b/src/input-helper.ts index 343f4a5..b1a2b7a 100644 --- a/src/input-helper.ts +++ b/src/input-helper.ts @@ -138,8 +138,9 @@ export async function getInputs(): Promise { // Auth token result.authToken = core.getInput('token', {required: true}) - // Git user - result.gitUser = core.getInput('git-user') || 'github-action[bot]' + // Configure user + result.configureUser = + (core.getInput('configure-user') || 'true').toUpperCase() === 'TRUE' // SSH result.sshKey = core.getInput('ssh-key')