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
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Set Node.js 24.x
|
||||
uses: actions/setup-node@v6
|
||||
|
|
@ -44,7 +44,7 @@ jobs:
|
|||
fi
|
||||
|
||||
# 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' }}
|
||||
with:
|
||||
name: dist
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v4
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
name: Check licenses
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v7
|
||||
- run: npm ci
|
||||
- run: npm run licensed-check
|
||||
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checking out
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
- name: Publish
|
||||
id: publish
|
||||
uses: actions/publish-immutable-action@v0.0.4
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ jobs:
|
|||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24.x
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v7
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- run: npm run format-check
|
||||
|
|
@ -37,7 +37,7 @@ jobs:
|
|||
steps:
|
||||
# Clone this repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
# Basic checkout
|
||||
- name: Checkout basic
|
||||
|
|
@ -229,7 +229,7 @@ jobs:
|
|||
steps:
|
||||
# Clone this repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
# Basic checkout using git
|
||||
- name: Checkout basic
|
||||
|
|
@ -261,7 +261,7 @@ jobs:
|
|||
steps:
|
||||
# Clone this repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
# Basic checkout using git
|
||||
- name: Checkout basic
|
||||
|
|
@ -291,7 +291,7 @@ jobs:
|
|||
steps:
|
||||
# Clone this repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
path: localClone
|
||||
|
||||
|
|
@ -314,12 +314,11 @@ jobs:
|
|||
fi
|
||||
|
||||
# Verify auth token
|
||||
git config --global --add safe.directory "*"
|
||||
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
||||
|
||||
# needed to make checkout post cleanup succeed
|
||||
- name: Fix Checkout v6
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
path: localClone
|
||||
|
||||
|
|
@ -328,7 +327,7 @@ jobs:
|
|||
steps:
|
||||
# Clone this repo
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
path: actions-checkout
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ jobs:
|
|||
# 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
|
||||
# (typically, about two releases back).
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Git config
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v7
|
||||
|
||||
# Use `docker/login-action` to log in to GHCR.io.
|
||||
# Once published, the packages are scoped to the account defined here.
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@ fi
|
|||
|
||||
cd "$CHECKOUT_PATH"
|
||||
|
||||
# Add safe directory for container environments
|
||||
git config --global --add safe.directory "*" 2>/dev/null || true
|
||||
|
||||
# Show the includeIf configuration
|
||||
echo "Git config includeIf entries:"
|
||||
git config --list --show-origin | grep -i include || true
|
||||
|
|
|
|||
|
|
@ -44,20 +44,14 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
if (git) {
|
||||
authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||
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
|
||||
// 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 addSafeDirectory(settings.repositoryPath, git, authHelper)
|
||||
const containerPath = getContainerRepositoryPath(
|
||||
settings.repositoryPath,
|
||||
settings.githubWorkspacePath
|
||||
)
|
||||
|
||||
await git
|
||||
.config('safe.directory', settings.repositoryPath, true, true)
|
||||
.catch(error => {
|
||||
core.info(
|
||||
`Failed to initialize safe directory with error: ${error}`
|
||||
)
|
||||
})
|
||||
if (containerPath && containerPath !== settings.repositoryPath) {
|
||||
await addSafeDirectory(containerPath, git, authHelper)
|
||||
}
|
||||
|
||||
stateHelper.setSafeDirectory()
|
||||
}
|
||||
|
|
@ -350,18 +344,7 @@ export async function cleanup(repositoryPath: string): Promise<void> {
|
|||
const authHelper = gitAuthHelper.createAuthHelper(git)
|
||||
try {
|
||||
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
|
||||
// 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 addSafeDirectory(repositoryPath, git, authHelper)
|
||||
}
|
||||
|
||||
await authHelper.removeAuth()
|
||||
|
|
@ -390,3 +373,39 @@ async function getGitCommandManager(
|
|||
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 {
|
||||
/**
|
||||
* The workflow workspace path
|
||||
*/
|
||||
githubWorkspacePath?: string
|
||||
|
||||
/**
|
||||
* 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')
|
||||
}
|
||||
githubWorkspacePath = path.resolve(githubWorkspacePath)
|
||||
result.githubWorkspacePath = githubWorkspacePath
|
||||
core.debug(`GITHUB_WORKSPACE = '${githubWorkspacePath}'`)
|
||||
fsHelper.directoryExistsSync(githubWorkspacePath, true)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue