Last active
March 25, 2025 08:59
-
-
Save Nolwennig/5b60def8ba7a40f42636 to your computer and use it in GitHub Desktop.
mise en prod ftp
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
############### | |
# Problem: | |
# faire une mise en prod avec le travail et les fichiers de qqn d'autre | |
# On a : un dépôt git local, un dépôt git preprod, un accès ftp (ou sftp) en prod | |
################# | |
# résolution | |
# 1*/ trouver la dernière mise en prod sur srv prod | |
# 1.1*/ cnx ftp -> check last date | |
# 2*/ faire le diff (git whatchanged) sur la preprod (plus stable que local) entre %last_date_modify_prod% et %now% (ou autre date) | |
# 2.1*/ générer le fichier mep.txt | |
# 3*/ transformer le fichier mep.txt en list d'upload filezilla | |
# 4*/ envoyer les fichiers avec filezilla (ATTENTION: bien se placer au bon endroit du srv prod) | |
################ | |
# génération fichier mep.txt | |
# from shell | |
# Liste tous les fichiers modifies entre x et x date | |
# Indispensable pour la suite | |
git whatchanged --since 'dd/mm/yyyy' --until 'dd/mm/yyyy' --oneline --name-only --pretty=format: | sort | uniq >> mep.txt | |
# Liste avec A (add) M (modif) D (delete) | |
# human file for information | |
git whatchanged --since 'dd/mm/yyyy' --until 'dd/mm/yyyy' --oneline --pretty=format: | sort | uniq >> mep_info.txt | |
--------------------- | |
<?php | |
// VARIABLES | |
$listPath = 'C:\Users\MY_USERNAME\mep.txt'; | |
$localPath = 'C:\wamp\www\MY_PROJECT'; | |
$ftp = array( | |
'host' => 'sub.domain.com', | |
'port' => '22', | |
'user' => 'ftp_user_name', | |
'pass' => 'ftp_password', | |
); | |
| |
// JOB | |
$files = file($listPath); | |
$xml = '<?xml version="1.0" encoding="UTF-8"?> | |
<FileZilla3 version="3.14.1" platform="windows"> | |
<Queue> | |
<Server> | |
<Host>' . $ftp['host'] . '</Host> | |
<Port>' . $ftp['port'] . '</Port> | |
<Protocol>1</Protocol> | |
<Type>0</Type> | |
<User>' . $ftp['user']. '</User> | |
<Pass encoding="base64">' . base64_encode($ftp['pass']) . '</Pass> | |
<Logontype>1</Logontype> | |
<TimezoneOffset>0</TimezoneOffset> | |
<PasvMode>MODE_DEFAULT</PasvMode> | |
<MaximumMultipleConnections>0</MaximumMultipleConnections> | |
<EncodingType>Auto</EncodingType> | |
<BypassProxy>0</BypassProxy>'; | |
| |
foreach($files as $file){ | |
$xml .= ' <File> | |
<LocalFile>'.$localPath.'\\'.str_replace('/', '\\', trim($file)).'</LocalFile> | |
<RemoteFile>'.trim($file).'</RemoteFile> | |
<RemotePath>1 0</RemotePath> | |
<Download>0</Download> | |
<DataType>0</DataType> | |
</File>'; | |
} | |
| |
$xml .= ' </Server> | |
</Queue> | |
</FileZilla3>'; | |
| |
// OUTPUT | |
echo $xml; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment