Compare commits

...

5 Commits

Author SHA1 Message Date
Marcus Wirtz a6b6ca7baf
Merge b23eb344e8 into 4f1f4aec02 2026-06-30 17:49:17 -04:00
dependabot[bot] 4f1f4aec02
Bump actions/upload-artifact from 4 to 7 (#2476)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-30 10:34:21 -04:00
dependabot[bot] ba097532fb
Bump actions/checkout from 6 to 7 (#2488)
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-30 10:33:37 -04:00
Marcus Wirtz b23eb344e8
Fix stuff 2026-04-21 12:30:04 +02:00
Marcus Wirtz a0eb51f8ea
fix: fix adding safe-directory in container 2026-04-21 11:32:17 +02:00
11 changed files with 64 additions and 43 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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)
}

View File

@ -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
*/ */

View File

@ -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)