Last active
October 11, 2021 03:25
-
-
Save iflamed/2d5aced9148714dcebe0c4918bcc917f to your computer and use it in GitHub Desktop.
Drone CI: git clone with ssh in the clone step
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
kind: pipeline | |
type: docker | |
name: default | |
clone: | |
disable: true | |
steps: | |
- name: clone | |
image: alpine/git | |
pull: if-not-exists | |
environment: | |
SSH_KEY: | |
from_secret: SSH_KEY | |
SSH_HOST: | |
from_secret: SSH_HOST | |
SSH_PORT: | |
from_secret: SSH_PORT | |
commands: | |
- mkdir $HOME/.ssh && echo "$SSH_KEY" > $HOME/.ssh/id_rsa && chmod 600 $HOME/.ssh/id_rsa | |
- | | |
[[ -n "$${SSH_PORT}" ]] && [[ -n "$${SSH_HOST}" ]] && ssh-keyscan -p $${SSH_PORT} $${SSH_HOST} >> $HOME/.ssh/known_hosts | |
- | | |
[[ -z "$${SSH_PORT}" ]] && [[ -n "$${SSH_HOST}" ]] && ssh-keyscan $${SSH_HOST} >> $HOME/.ssh/known_hosts | |
- git clone ${DRONE_GIT_SSH_URL} . | |
- git checkout ${DRONE_COMMIT_BRANCH} | |
- name: greeting | |
image: alpine | |
pull: if-not-exists | |
commands: | |
- echo "hello, world" | |
- ls -ahl | |
- pwd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如果要放到git上的确实会不安全,我这里没放,都是直接在本地编辑的。