diff --git a/action.yml b/action.yml index a0917501..2f5777cb 100644 --- a/action.yml +++ b/action.yml @@ -110,6 +110,11 @@ inputs: required: false default: '' description: 'SSH Agent path to forward to the container' + gitPrivateToken: + required: false + default: '' + description: > + Github private token to pull from github chownFilesTo: required: false default: '' diff --git a/dist/entrypoint.sh b/dist/entrypoint.sh index 4841be00..a8d382dc 100755 --- a/dist/entrypoint.sh +++ b/dist/entrypoint.sh @@ -10,7 +10,7 @@ mkdir -p "$ACTIVATE_LICENSE_PATH" # # Run steps # - +source /steps/set_gitcredential.sh source /steps/activate.sh source /steps/build.sh source /steps/return_license.sh diff --git a/dist/index.js b/dist/index.js index 4f579c14..07e91231 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index 3a0f3bc7..02f943ac 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/dist/steps/set_gitcredential.sh b/dist/steps/set_gitcredential.sh new file mode 100755 index 00000000..6c8de5d9 --- /dev/null +++ b/dist/steps/set_gitcredential.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +if [ -z "${GIT_PRIVATE_TOKEN}" ] +then + echo "GIT_PRIVATE_TOKEN unset skipping" +else + echo "GIT_PRIVATE_TOKEN is set configuring git credentials" + + git config --global credential.helper store + git config --global --replace-all url.https://github.com/.insteadOf ssh://git@github.com/ + git config --global --add url.https://github.com/.insteadOf git@github.com + + git config --global url."https://token:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "https://github.com/" + git config --global url."https://ssh:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "ssh://git@github.com/" + git config --global url."https://git:$GIT_PRIVATE_TOKEN@github.com/".insteadOf "git@github.com:" + +fi + +echo "---------- git config --list -------------" +git config --list + +echo "---------- git config --list --show-origin -------------" +git config --list --show-origin + diff --git a/src/model/__mocks__/input.ts b/src/model/__mocks__/input.ts index 33f1091a..438496a1 100644 --- a/src/model/__mocks__/input.ts +++ b/src/model/__mocks__/input.ts @@ -12,6 +12,7 @@ export const mockGetFromUser = jest.fn().mockResolvedValue({ customParameters: '', sshAgent: '', chownFilesTo: '', + gitPrivateToken: '', }); export default { diff --git a/src/model/build-parameters.ts b/src/model/build-parameters.ts index e3a48fad..3c1439e2 100644 --- a/src/model/build-parameters.ts +++ b/src/model/build-parameters.ts @@ -23,6 +23,7 @@ class BuildParameters { public androidKeyaliasPass!: string; public customParameters!: string; public sshAgent!: string; + public gitPrivateToken!: string; public remoteBuildCluster!: string; public awsStackName!: string; public kubeConfig!: string; @@ -62,6 +63,7 @@ class BuildParameters { androidKeyaliasPass: Input.androidKeyaliasPass, customParameters: Input.customParameters, sshAgent: Input.sshAgent, + gitPrivateToken: Input.gitPrivateToken, chownFilesTo: Input.chownFilesTo, remoteBuildCluster: Input.remoteBuildCluster, awsStackName: Input.awsStackName, diff --git a/src/model/docker.ts b/src/model/docker.ts index d0f8915f..432286bf 100644 --- a/src/model/docker.ts +++ b/src/model/docker.ts @@ -37,6 +37,7 @@ class Docker { androidKeyaliasPass, customParameters, sshAgent, + gitPrivateToken, chownFilesTo, } = parameters; @@ -80,6 +81,7 @@ class Docker { --env RUNNER_TOOL_CACHE \ --env RUNNER_TEMP \ --env RUNNER_WORKSPACE \ + --env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \ ${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \ --volume "/var/run/docker.sock":"/var/run/docker.sock" \ --volume "${runnerTempPath}/_github_home":"/root" \ diff --git a/src/model/input.ts b/src/model/input.ts index 5c5b8667..c7a06933 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -89,6 +89,10 @@ class Input { return core.getInput('sshAgent') || ''; } + static get gitPrivateToken() { + return core.getInput('gitPrivateToken') || ''; + } + static get chownFilesTo() { return core.getInput('chownFilesTo') || ''; }