Merge pull request #1 from mad01/git-config

Git config
pull/278/head
Alexander Brandstedt 2021-07-13 13:18:57 +02:00 committed by GitHub
commit 87d7d936bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 2176 additions and 2123 deletions

View File

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

2
dist/entrypoint.sh vendored
View File

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

9
dist/index.js vendored
View File

@ -230,6 +230,7 @@ class BuildParameters {
androidKeyaliasPass: input_1.default.androidKeyaliasPass, androidKeyaliasPass: input_1.default.androidKeyaliasPass,
customParameters: input_1.default.customParameters, customParameters: input_1.default.customParameters,
sshAgent: input_1.default.sshAgent, sshAgent: input_1.default.sshAgent,
gitCredential: input_1.default.gitCredential,
chownFilesTo: input_1.default.chownFilesTo, chownFilesTo: input_1.default.chownFilesTo,
remoteBuildCluster: input_1.default.remoteBuildCluster, remoteBuildCluster: input_1.default.remoteBuildCluster,
awsStackName: input_1.default.awsStackName, awsStackName: input_1.default.awsStackName,
@ -347,7 +348,7 @@ class Docker {
} }
static run(image, parameters, silent = false) { static run(image, parameters, silent = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { version, workspace, runnerTempPath, platform, projectPath, buildName, buildPath, buildFile, buildMethod, buildVersion, androidVersionCode, androidKeystoreName, androidKeystoreBase64, androidKeystorePass, androidKeyaliasName, androidKeyaliasPass, customParameters, sshAgent, chownFilesTo, } = parameters; const { version, workspace, runnerTempPath, platform, projectPath, buildName, buildPath, buildFile, buildMethod, buildVersion, androidVersionCode, androidKeystoreName, androidKeystoreBase64, androidKeystorePass, androidKeyaliasName, androidKeyaliasPass, customParameters, sshAgent, gitCredential, chownFilesTo, } = parameters;
const command = `docker run \ const command = `docker run \
--workdir /github/workspace \ --workdir /github/workspace \
--rm \ --rm \
@ -388,6 +389,7 @@ class Docker {
--env RUNNER_TOOL_CACHE \ --env RUNNER_TOOL_CACHE \
--env RUNNER_TEMP \ --env RUNNER_TEMP \
--env RUNNER_WORKSPACE \ --env RUNNER_WORKSPACE \
${gitCredential ? '--env GIT_CREDENTIAL' : ''} \
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \ ${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
--volume "/var/run/docker.sock":"/var/run/docker.sock" \ --volume "/var/run/docker.sock":"/var/run/docker.sock" \
--volume "${runnerTempPath}/_github_home":"/root" \ --volume "${runnerTempPath}/_github_home":"/root" \
@ -669,6 +671,9 @@ class Input {
static get sshAgent() { static get sshAgent() {
return core.getInput('sshAgent') || ''; return core.getInput('sshAgent') || '';
} }
static get gitCredential() {
return core.getInput('gitCredential') || '';
}
static get chownFilesTo() { static get chownFilesTo() {
return core.getInput('chownFilesTo') || ''; return core.getInput('chownFilesTo') || '';
} }
@ -156351,7 +156356,7 @@ const testParameter = (name, filters) => {
}; };
const normalizeDataURL = (urlString, {stripHash}) => { const normalizeDataURL = (urlString, {stripHash}) => {
const parts = urlString.match(/^data:(.*?),(.*?)(?:#(.*))?$/); const parts = urlString.match(/^data:([^,]*?),([^#]*?)(?:#(.*))?$/);
if (!parts) { if (!parts) {
throw new Error(`Invalid URL: ${urlString}`); throw new Error(`Invalid URL: ${urlString}`);

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

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

@ -0,0 +1,32 @@
#!/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: '', customParameters: '',
sshAgent: '', sshAgent: '',
chownFilesTo: '', chownFilesTo: '',
gitCredential: '',
}); });
export default { export default {

View File

@ -23,6 +23,7 @@ class BuildParameters {
public androidKeyaliasPass!: string; public androidKeyaliasPass!: string;
public customParameters!: string; public customParameters!: string;
public sshAgent!: string; public sshAgent!: string;
public gitCredential!: string;
public remoteBuildCluster!: string; public remoteBuildCluster!: string;
public awsStackName!: string; public awsStackName!: string;
public kubeConfig!: string; public kubeConfig!: string;
@ -62,6 +63,7 @@ class BuildParameters {
androidKeyaliasPass: Input.androidKeyaliasPass, androidKeyaliasPass: Input.androidKeyaliasPass,
customParameters: Input.customParameters, customParameters: Input.customParameters,
sshAgent: Input.sshAgent, sshAgent: Input.sshAgent,
gitCredential: Input.gitCredential,
chownFilesTo: Input.chownFilesTo, chownFilesTo: Input.chownFilesTo,
remoteBuildCluster: Input.remoteBuildCluster, remoteBuildCluster: Input.remoteBuildCluster,
awsStackName: Input.awsStackName, awsStackName: Input.awsStackName,

View File

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

View File

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