adding option to pass git credential

pull/278/head
Alexander Brandstedt 2021-07-13 09:51:40 +02:00
parent 36364461d5
commit ad14aecdb4
7 changed files with 53 additions and 1 deletions

View File

@ -110,6 +110,13 @@ inputs:
required: false
default: ''
description: 'SSH Agent path to forward to the container'
gitCredential:
required: false
default: ''
description: >
Git credential configuration
example: https://$token@github.com/
chownFilesTo:
required: false
default: ''

2
dist/entrypoint.sh vendored
View File

@ -3,7 +3,7 @@
#
# Run steps
#
source /steps/set_gitcredential.sh
source /steps/activate.sh
source /steps/build.sh
source /steps/return_license.sh

36
dist/steps/set_gitcredential.sh vendored 100755
View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
set_config_home() {
if [ -z "${XDG_CONFIG_HOME}" ]
then
mkdir -p "${HOME}/.config"
export XDG_CONFIG_HOME="${HOME}/.config"
fi
mkdir -p "${XDG_CONFIG_HOME}/git"
}
configure_git_credentials() {
echo "${GIT_CREDENTIAL}" >> "${XDG_CONFIG_HOME}/git/credentials"
chmod 0600 "${XDG_CONFIG_HOME}/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
}
if [ -z "${GIT_CREDENTIAL}" ]
then
echo "GIT_CREDENTIAL unset skipping"
else
echo "GIT_CREDENTIAL is set configuring git credentials"
set_config_home
configure_git_credentials
fi

View File

@ -12,6 +12,7 @@ export const mockGetFromUser = jest.fn().mockResolvedValue({
customParameters: '',
sshAgent: '',
chownFilesTo: '',
gitCredential: '',
});
export default {

View File

@ -23,6 +23,7 @@ class BuildParameters {
public androidKeyaliasPass!: string;
public customParameters!: string;
public sshAgent!: string;
public gitCredential!: 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,
gitCredential: Input.gitCredential,
chownFilesTo: Input.chownFilesTo,
remoteBuildCluster: Input.remoteBuildCluster,
awsStackName: Input.awsStackName,

View File

@ -37,6 +37,7 @@ class Docker {
androidKeyaliasPass,
customParameters,
sshAgent,
gitCredential,
chownFilesTo,
} = parameters;
@ -80,6 +81,7 @@ class Docker {
--env RUNNER_TOOL_CACHE \
--env RUNNER_TEMP \
--env RUNNER_WORKSPACE \
${gitCredential ? '--env GIT_CREDENTIAL': ''} \
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
--volume "${runnerTempPath}/_github_home":"/root" \

View File

@ -89,6 +89,10 @@ class Input {
return core.getInput('sshAgent') || '';
}
static get gitCredential() {
return core.getInput('gitCredential') || '';
}
static get chownFilesTo() {
return core.getInput('chownFilesTo') || '';
}