mirror of https://github.com/actions/checkout
Compare commits
7 Commits
95e11df6f2
...
b88c178311
| Author | SHA1 | Date |
|---|---|---|
|
|
b88c178311 | |
|
|
b9e0990d21 | |
|
|
e8cb398be4 | |
|
|
5de26ee9b1 | |
|
|
79102f2503 | |
|
|
b23eb344e8 | |
|
|
a0eb51f8ea |
|
|
@ -25,7 +25,7 @@ jobs:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set Node.js 24.x
|
- name: Set Node.js 24.x
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ jobs:
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v3
|
uses: github/codeql-action/init@v4
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
|
@ -55,4 +55,4 @@ jobs:
|
||||||
- run: rm -rf dist # We want code scanning to analyze lib instead (individual .js files)
|
- run: rm -rf dist # We want code scanning to analyze lib instead (individual .js files)
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v3
|
uses: github/codeql-action/analyze@v4
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
|
@ -314,7 +314,6 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify auth token
|
# Verify auth token
|
||||||
git config --global --add safe.directory "*"
|
|
||||||
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
||||||
|
|
||||||
# needed to make checkout post cleanup succeed
|
# needed to make checkout post cleanup succeed
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ jobs:
|
||||||
# Use `docker/login-action` to log in to GHCR.io.
|
# Use `docker/login-action` to log in to GHCR.io.
|
||||||
# Once published, the packages are scoped to the account defined here.
|
# Once published, the packages are scoped to the account defined here.
|
||||||
- name: Log in to the ghcr.io container registry
|
- name: Log in to the ghcr.io container registry
|
||||||
uses: docker/login-action@v3.3.0
|
uses: docker/login-action@v4.2.0
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
|
@ -48,7 +48,7 @@ jobs:
|
||||||
|
|
||||||
# Use `docker/build-push-action` to build (and optionally publish) the image.
|
# Use `docker/build-push-action` to build (and optionally publish) the image.
|
||||||
- name: Build Docker Image (with optional Push)
|
- name: Build Docker Image (with optional Push)
|
||||||
uses: docker/build-push-action@v6.5.0
|
uses: docker/build-push-action@v7.2.0
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: images/test-ubuntu-git.Dockerfile
|
file: images/test-ubuntu-git.Dockerfile
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,6 @@ fi
|
||||||
|
|
||||||
cd "$CHECKOUT_PATH"
|
cd "$CHECKOUT_PATH"
|
||||||
|
|
||||||
# Add safe directory for container environments
|
|
||||||
git config --global --add safe.directory "*" 2>/dev/null || true
|
|
||||||
|
|
||||||
# Show the includeIf configuration
|
# Show the includeIf configuration
|
||||||
echo "Git config includeIf entries:"
|
echo "Git config includeIf entries:"
|
||||||
git config --list --show-origin | grep -i include || true
|
git config --list --show-origin | grep -i include || true
|
||||||
|
|
|
||||||
|
|
@ -44,20 +44,14 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||||
if (git) {
|
if (git) {
|
||||||
authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
if (settings.setSafeDirectory) {
|
if (settings.setSafeDirectory) {
|
||||||
// Setup the repository path as a safe directory, so if we pass this into a container job with a different user it doesn't fail
|
await addSafeDirectory(settings.repositoryPath, git, authHelper)
|
||||||
// Otherwise all git commands we run in a container fail
|
const containerPath = getContainerRepositoryPath(
|
||||||
await authHelper.configureTempGlobalConfig()
|
settings.repositoryPath,
|
||||||
core.info(
|
settings.githubWorkspacePath
|
||||||
`Adding repository directory to the temporary git global config as a safe directory`
|
|
||||||
)
|
)
|
||||||
|
if (containerPath && containerPath !== settings.repositoryPath) {
|
||||||
await git
|
await addSafeDirectory(containerPath, git, authHelper)
|
||||||
.config('safe.directory', settings.repositoryPath, true, true)
|
}
|
||||||
.catch(error => {
|
|
||||||
core.info(
|
|
||||||
`Failed to initialize safe directory with error: ${error}`
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
stateHelper.setSafeDirectory()
|
stateHelper.setSafeDirectory()
|
||||||
}
|
}
|
||||||
|
|
@ -350,18 +344,7 @@ export async function cleanup(repositoryPath: string): Promise<void> {
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git)
|
const authHelper = gitAuthHelper.createAuthHelper(git)
|
||||||
try {
|
try {
|
||||||
if (stateHelper.PostSetSafeDirectory) {
|
if (stateHelper.PostSetSafeDirectory) {
|
||||||
// Setup the repository path as a safe directory, so if we pass this into a container job with a different user it doesn't fail
|
await addSafeDirectory(repositoryPath, git, authHelper)
|
||||||
// Otherwise all git commands we run in a container fail
|
|
||||||
await authHelper.configureTempGlobalConfig()
|
|
||||||
core.info(
|
|
||||||
`Adding repository directory to the temporary git global config as a safe directory`
|
|
||||||
)
|
|
||||||
|
|
||||||
await git
|
|
||||||
.config('safe.directory', repositoryPath, true, true)
|
|
||||||
.catch(error => {
|
|
||||||
core.info(`Failed to initialize safe directory with error: ${error}`)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await authHelper.removeAuth()
|
await authHelper.removeAuth()
|
||||||
|
|
@ -390,3 +373,39 @@ async function getGitCommandManager(
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function addSafeDirectory(
|
||||||
|
safeDirectory: string,
|
||||||
|
git: IGitCommandManager,
|
||||||
|
authHelper: gitAuthHelper.IGitAuthHelper
|
||||||
|
): Promise<void> {
|
||||||
|
await authHelper.configureTempGlobalConfig()
|
||||||
|
core.info(`Adding '${safeDirectory}' to the git global config as a safe directory`)
|
||||||
|
await git.config('safe.directory', safeDirectory, true, true).catch(error => {
|
||||||
|
core.info(`Failed to initialize safe directory with error: ${error}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContainerRepositoryPath(
|
||||||
|
repositoryPath: string,
|
||||||
|
githubWorkspace?: string
|
||||||
|
): string {
|
||||||
|
if (!githubWorkspace) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
let relativeRepositoryPath = path.relative(githubWorkspace, repositoryPath)
|
||||||
|
if (!relativeRepositoryPath || relativeRepositoryPath === '.') {
|
||||||
|
return '/github/workspace'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
relativeRepositoryPath.startsWith('..') ||
|
||||||
|
path.isAbsolute(relativeRepositoryPath)
|
||||||
|
) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
relativeRepositoryPath = relativeRepositoryPath.replace(/\\/g, '/')
|
||||||
|
return path.posix.join('/github/workspace', relativeRepositoryPath)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
export interface IGitSourceSettings {
|
export interface IGitSourceSettings {
|
||||||
|
/**
|
||||||
|
* The workflow workspace path
|
||||||
|
*/
|
||||||
|
githubWorkspacePath?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location on disk where the repository will be placed
|
* The location on disk where the repository will be placed
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
||||||
throw new Error('GITHUB_WORKSPACE not defined')
|
throw new Error('GITHUB_WORKSPACE not defined')
|
||||||
}
|
}
|
||||||
githubWorkspacePath = path.resolve(githubWorkspacePath)
|
githubWorkspacePath = path.resolve(githubWorkspacePath)
|
||||||
|
result.githubWorkspacePath = githubWorkspacePath
|
||||||
core.debug(`GITHUB_WORKSPACE = '${githubWorkspacePath}'`)
|
core.debug(`GITHUB_WORKSPACE = '${githubWorkspacePath}'`)
|
||||||
fsHelper.directoryExistsSync(githubWorkspacePath, true)
|
fsHelper.directoryExistsSync(githubWorkspacePath, true)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue