Skip to content

Commit 95c44bb

Browse files
committed
fix gh ci clone
1 parent 9278e46 commit 95c44bb

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "git-ai"
3-
version = "1.0.8"
3+
version = "1.0.9"
44
edition = "2024"
55

66

src/ci/github.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,20 @@ pub fn get_github_ci_context() -> Result<Option<CiContext>, GitAiError> {
6161

6262
let clone_dir = "git-ai-ci-clone".to_string();
6363

64+
// Authenticate the clone URL with GITHUB_TOKEN if available
65+
let authenticated_url = if let Ok(token) = std::env::var("GITHUB_TOKEN") {
66+
// Replace https://github.com/ with https://x-access-token:TOKEN@github.com/
67+
clone_url.replace("https://github.com/", &format!("https://x-access-token:{}@github.com/", token))
68+
} else {
69+
clone_url
70+
};
71+
6472
// Clone the repo
6573
exec_git(&[
6674
"clone".to_string(),
6775
"--branch".to_string(),
6876
base_ref.clone(),
69-
clone_url,
77+
authenticated_url,
7078
clone_dir.clone(),
7179
])?;
7280

src/ci/workflow_templates/github.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
echo "$HOME/.git-ai/bin" >> $GITHUB_PATH
1818
- name: Run git-ai
1919
id: run-git-ai
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2022
run: |
2123
git config --global user.name "github-actions[bot]"
2224
git config --global user.email "github-actions[bot]@users.noreply.github.com"

0 commit comments

Comments
 (0)