Created
July 7, 2017 19:11
-
-
Save stevenquiroa/ea90f915f00f054433e22a91fbfd98da to your computer and use it in GitHub Desktop.
Bitbucket-pipelines, ssh, git-ftp
This file contains 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
#Imagen con debian y git para el container. | |
#Se utiliza especificamente esta porque git-ftp necesita el paquete de git para funcionar | |
#Declaramos la imagen a utilizar | |
image: samueldebruyn/debian-git | |
#Iniciamos el pipeline | |
pipelines: | |
default: | |
- step: | |
script: | |
#instalamos git-ftp | |
- apt-get update && apt-get install -y git-ftp | |
#agregamos la ssh key a nuestro container | |
- echo $MY_SSH_KEY > /root/.ssh/id_rsa.pub | |
#Verificamos que las dos keys esten (OPCIONAL). | |
#Ubicacion de la llave publica. | |
- cat /root/.ssh/id_rsa.pub #(OPCIONAL) | |
#Ubiacacion de la llave privada. | |
- cat /opt/atlassian/pipelines/agent/data/id_rsa #(OPCIONAL) | |
#En caso de que no este en el archivo de arriba, según la documentación de julio 2017 | |
#Podemos encontrar la ruta si le damos un cat al ~/.ssh/config | |
#Corremos el comando comentado abajo. Y lo cambios por la ruta de la llave privada | |
#-cat ~/.ssh/config | |
#SETEAMOS LOS PARAMETROS NECESARIOS PARA QUE GIT-FTP PUEDA ENTRAR A NUESTRO SERVIDOR | |
- git config git-ftp.user exampleuser #Usuario de ssh | |
- git config git-ftp.key /opt/atlassian/pipelines/agent/data/id_rsa #Ubicacion completa de la llave privada (NO UTILIZAR RUTAS RESUMIDAS) | |
#Ubicacion completa de la llave publica (NO UTILIZAR RUTAS RESUMIDAS) | |
- git config git-ftp.pubkey /root/.ssh/id_rsa.pub | |
#Ubicacion del folder a donde se van a guardar los archivos | |
#Esta debe ser la url desde la raiz del server | |
#En este caso la url se separa por (protocolo)://(hostname)(path) | |
- git config git-ftp.url sftp://example.hostgator.com/path/to/folder | |
# - git ftp init --insecure --verbose --user root --key "" --pubkey "/root/.ssh/id_rsa.pub" "sftp://api.warava.com/home/steven/workspace/docker/housebook/" | |
#Hacemos el push de nuestro codigo al servidor | |
#(--verbose es para que despliegue todo el error de una manera mas extendida) | |
- git ftp push --verbose | |
#Este ultimo comando es para ejecutar una serie de comandos despues de hacer un deploy | |
#Puede ser como limpiar el folder para quitar todos los .md del proyecto, hacer un migrate, etc | |
- ssh -T exampleuser@example.hostgator.com "cd /path/to/folder; chmod +x ./deploy.sh; ./deploy.sh" |
This file contains 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
#!/bin/bash | |
shopt -s extglob | |
rm -rf *.md |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment