@@ -27,38 +27,19 @@ decode_or_raw() {
2727 esac
2828}
2929
30- # Decode SSH keys (separate keys for GitHub and GitLab )
31- if [ -n " ${SSH_PRIVATE_KEY_B64 :- } " ] ; then
32- decode_or_raw " $SSH_PRIVATE_KEY_B64 " > ~ /.ssh/id_gh
33- chmod 600 ~ /.ssh/id_gh
34- unset SSH_PRIVATE_KEY_B64
35- fi
36-
37- if [ -n " ${GITLAB_SSH_KEY_B64 :- } " ] ; then
38- decode_or_raw " $GITLAB_SSH_KEY_B64 " > ~ /.ssh/id_gl
39- chmod 600 ~ /.ssh/id_gl
40- unset GITLAB_SSH_KEY_B64
30+ # Git credential helpers for HTTPS auth (replaces SSH keys )
31+ # GitHub: gh CLI acts as credential helper
32+ # GitLab: custom helper script injects token
33+ if [ -n " ${GITLAB_TOKEN :- } " ] ; then
34+ cat > /home/botuser/.git-credential-gitlab << CREDEOF
35+ #!/bin/bash
36+ echo "username= ${GITLAB_USERNAME} "
37+ echo "password= ${GITLAB_TOKEN} "
38+ CREDEOF
39+ chmod 700 /home/botuser/.git-credential-gitlab
40+ git config --global credential.https://gitlab.cee.redhat.com.helper " /home/botuser/.git-credential-gitlab "
4141fi
4242
43- # Generate SSH config — PROXY_HOST defaults to "proxy" (matches docker-compose service name)
44- PROXY_HOST=" ${PROXY_HOST:- proxy} "
45- cat > ~ /.ssh/config << SSHEOF
46- Host github.com
47- HostName github.com
48- User git
49- IdentityFile /home/botuser/.ssh/id_gh
50- IdentitiesOnly yes
51- StrictHostKeyChecking accept-new
52- ProxyCommand socat - PROXY:${PROXY_HOST} :%h:%p,proxyport=3128
53-
54- Host gitlab.cee.redhat.com
55- IdentityFile /home/botuser/.ssh/id_gl
56- IdentitiesOnly yes
57- StrictHostKeyChecking accept-new
58- ProxyCommand socat - PROXY:${PROXY_HOST} :%h:%p,proxyport=3128
59- SSHEOF
60- chmod 600 ~ /.ssh/config
61-
6243# Write SSO credentials file for stage auth (chrome-devtools)
6344if [ -n " ${SSO_USERNAME:- } " ] && [ -n " ${SSO_PASSWORD:- } " ]; then
6445 cat > /home/botuser/app/.credentials << EOF
6849 unset SSO_USERNAME SSO_PASSWORD
6950fi
7051
52+ # Git identity from env vars
53+ git config --global user.name " ${GIT_USER_NAME} "
54+ git config --global user.email " ${GIT_USER_EMAIL} "
55+
7156# Import GPG key for commit signing
7257if [ -n " ${GPG_PRIVATE_KEY_B64:- } " ]; then
7358 gpg --batch --import <( decode_or_raw " $GPG_PRIVATE_KEY_B64 " ) 2> /dev/null
8368# Point MCP config to the memory server
8469sed -i " s|http://localhost:8080/mcp|${BOT_MEMORY_URL} |" .mcp.json
8570
86- # Configure gh CLI auth
71+ # Configure gh CLI auth (HTTPS + credential helper for git)
8772mkdir -p ~ /.config/gh
8873cat > ~ /.config/gh/hosts.yml << EOF
8974github.com:
9075 oauth_token: ${GH_TOKEN}
91- user: platex-rehor-bot
92- git_protocol: ssh
76+ user: ${GH_USERNAME}
77+ git_protocol: https
9378EOF
79+ gh auth setup-git 2> /dev/null || true
9480
9581# Remove token from env — gh uses the config file from now on
9682unset GH_TOKEN
@@ -99,7 +85,7 @@ unset GH_TOKEN
9985if [ -n " ${GITLAB_TOKEN:- } " ]; then
10086 mkdir -p ~ /.config/glab-cli
10187 cat > ~ /.config/glab-cli/config.yml << EOF
102- git_protocol: ssh
88+ git_protocol: https
10389check_update: false
10490no_prompt: true
10591host: gitlab.cee.redhat.com
@@ -108,7 +94,7 @@ hosts:
10894 token: ${GITLAB_TOKEN}
10995 api_protocol: https
11096 api_host: gitlab.cee.redhat.com
111- git_protocol: ssh
97+ git_protocol: https
11298 skip_tls_verify: true
11399EOF
114100 chmod 600 ~ /.config/glab-cli/config.yml
@@ -162,5 +148,5 @@ CHROME_BIN=$(find "$PLAYWRIGHT_BROWSERS_PATH" -name chrome -type f | head -1)
162148# Wait for Chromium to be ready
163149until curl -s http://127.0.0.1:9222/json/version > /dev/null 2>&1 ; do sleep 1; done
164150
165- echo " Keys loaded . Chromium started. Starting bot with label: ${BOT_LABEL} "
151+ echo " Credentials configured . Chromium started. Starting bot with label: ${BOT_LABEL} "
166152exec uv run dev-bot --label " $BOT_LABEL "
0 commit comments