Skip to content

Commit ede85d0

Browse files
committed
add ssh
1 parent b185244 commit ede85d0

1 file changed

Lines changed: 30 additions & 12 deletions

File tree

.ci/skills-gen.cloudbuild.yaml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,27 @@
1313
# limitations under the License.
1414

1515
steps:
16+
- id: "setup-ssh"
17+
name: "gcr.io/cloud-builders/git"
18+
entrypoint: "bash"
19+
secretEnv:
20+
- "GITHUB_TOKEN"
21+
volumes:
22+
- name: "ssh-keys"
23+
path: /root/.ssh
24+
args:
25+
- -c
26+
- |
27+
# Write the secret key to the shared volume and secure it
28+
echo "$$GITHUB_TOKEN" > /root/.ssh/id_ed25519
29+
chmod 400 /root/.ssh/id_ed25519
30+
31+
# Scan GitHub's server to prevent interactive prompts
32+
ssh-keyscan -t rsa github.com > /root/.ssh/known_hosts
33+
1634
- id: "generate-skills"
1735
name: "node:20"
36+
waitFor: ["setup-ssh"]
1837
entrypoint: "bash"
1938
env:
2039
- "CLOUD_SQL_POSTGRES_PROJECT=$PROJECT_ID"
@@ -27,25 +46,24 @@ steps:
2746
args:
2847
- -c
2948
- |
30-
# Read the version and export it so the script can use it
3149
export VERSION=$$(cat toolbox_version.txt | tr -d '\n')
3250
echo "Detected toolbox version: $$VERSION"
33-
51+
3452
chmod +x ./.ci/scripts/generate_skills.sh
3553
./.ci/scripts/generate_skills.sh
3654
3755
- id: "commit-and-push"
3856
name: "gcr.io/cloud-builders/git"
3957
waitFor: ["generate-skills"]
4058
entrypoint: "bash"
41-
secretEnv:
42-
- "GITHUB_TOKEN"
59+
volumes:
60+
- name: "ssh-keys" # This mounts the keys generated in Step 1
61+
path: /root/.ssh
4362
args:
4463
- -c
4564
- |
4665
git config --global --add safe.directory '*'
47-
48-
# Check if the script actually created/changed any files
66+
4967
if [ -z "$$(git status --porcelain)" ]; then
5068
echo "No new files generated. Exiting without committing."
5169
exit 0
@@ -54,21 +72,21 @@ steps:
5472
echo "Changes detected. Preparing to commit..."
5573
git config --global user.email "cloudbuild@google.com"
5674
git config --global user.name "Cloud Build Bot"
57-
58-
# Authenticate and push
59-
git remote set-url origin https://x-access-token:$$GITHUB_TOKEN@github.com/gemini-cli-extensions/cloud-sql-postgresql.git
75+
76+
# We can now just push natively using the SSH URL!
77+
git remote set-url origin git@github.com:gemini-cli-extensions/cloud-sql-postgresql.git
6078
git add .
6179
git commit -m "chore: auto-generate skills based on toolbox_version.txt update"
6280
git push origin HEAD:$_HEAD_BRANCH
6381
6482
availableSecrets:
6583
secretManager:
6684
- versionName: projects/$PROJECT_ID/secrets/cloud_sql_pg_user/versions/latest
67-
env: 'CLOUD_SQL_POSTGRES_USER'
85+
env: "CLOUD_SQL_POSTGRES_USER"
6886
- versionName: projects/$PROJECT_ID/secrets/cloud_sql_pg_pass/versions/latest
69-
env: 'CLOUD_SQL_POSTGRES_PASSWORD'
87+
env: "CLOUD_SQL_POSTGRES_PASSWORD"
7088
- versionName: projects/$PROJECT_ID/secrets/github_token_cloud_sql_postgresql/versions/latest
71-
env: 'GITHUB_TOKEN'
89+
env: "GITHUB_TOKEN"
7290

7391
options:
7492
logging: CLOUD_LOGGING_ONLY

0 commit comments

Comments
 (0)