fix: authenticate gitea lfs uploads
This commit is contained in:
+16
-1
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user