fix: authenticate gitea lfs uploads

This commit is contained in:
Tom Boullay
2026-05-15 01:19:22 +02:00
parent f53f606daa
commit 71b4b2c905
3 changed files with 20 additions and 1 deletions
+16 -1
View File
@@ -65,6 +65,21 @@ function getGitToken() {
return token
}
function getGitUsername() {
return process.env.GIT_USERNAME?.trim()
}
function getLfsAuthorizationHeader(remote: GitRemoteConfig) {
if (remote.provider === 'github') return `token ${remote.token}`
const username = getGitUsername()
if (!username) {
throw new Error('GIT_USERNAME non configure pour Git LFS sur Gitea')
}
return `Basic ${Buffer.from(`${username}:${remote.token}`, 'utf-8').toString('base64')}`
}
function getOctokit(remote: GitRemoteConfig): Octokit {
return new Octokit({
auth: remote.token,
@@ -295,7 +310,7 @@ async function uploadToLfsBatch(
headers: {
'Accept': 'application/vnd.git-lfs+json',
'Content-Type': 'application/vnd.git-lfs+json',
'Authorization': `token ${remote.token}`,
'Authorization': getLfsAuthorizationHeader(remote),
},
body: JSON.stringify({
operation: 'upload',