mirror of https://github.com/actions/checkout
Compare commits
5 Commits
b88c178311
...
a6b6ca7baf
| Author | SHA1 | Date |
|---|---|---|
|
|
a6b6ca7baf | |
|
|
4f1f4aec02 | |
|
|
ba097532fb | |
|
|
b23eb344e8 | |
|
|
a0eb51f8ea |
|
|
@ -22,7 +22,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Set Node.js 24.x
|
- name: Set Node.js 24.x
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
|
|
@ -44,7 +44,7 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If dist/ was different than expected, upload the expected version as an artifact
|
# If dist/ was different than expected, upload the expected version as an artifact
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v7
|
||||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v4
|
uses: github/codeql-action/init@v4
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,6 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Check licenses
|
name: Check licenses
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run licensed-check
|
- run: npm run licensed-check
|
||||||
|
|
@ -14,7 +14,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checking out
|
- name: Checking out
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
- name: Publish
|
- name: Publish
|
||||||
id: publish
|
id: publish
|
||||||
uses: actions/publish-immutable-action@v0.0.4
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ jobs:
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run format-check
|
- run: npm run format-check
|
||||||
|
|
@ -37,7 +37,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
# Basic checkout
|
# Basic checkout
|
||||||
- name: Checkout basic
|
- name: Checkout basic
|
||||||
|
|
@ -229,7 +229,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
# Basic checkout using git
|
# Basic checkout using git
|
||||||
- name: Checkout basic
|
- name: Checkout basic
|
||||||
|
|
@ -261,7 +261,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
# Basic checkout using git
|
# Basic checkout using git
|
||||||
- name: Checkout basic
|
- name: Checkout basic
|
||||||
|
|
@ -291,7 +291,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
path: localClone
|
path: localClone
|
||||||
|
|
||||||
|
|
@ -314,12 +314,11 @@ 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
|
||||||
- name: Fix Checkout v6
|
- name: Fix Checkout v6
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
path: localClone
|
path: localClone
|
||||||
|
|
||||||
|
|
@ -328,7 +327,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
# Clone this repo
|
# Clone this repo
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
path: actions-checkout
|
path: actions-checkout
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ jobs:
|
||||||
# Note this update workflow can also be used as a rollback tool.
|
# Note this update workflow can also be used as a rollback tool.
|
||||||
# For that reason, it's best to pin `actions/checkout` to a known, stable version
|
# For that reason, it's best to pin `actions/checkout` to a known, stable version
|
||||||
# (typically, about two releases back).
|
# (typically, about two releases back).
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Git config
|
- name: Git config
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
|
||||||
|
|
@ -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