Synchronisation des builds #8
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
name: Synchronisation des builds | |
on: | |
schedule: | |
- cron: "0 */6 1 1 1" | |
workflow_dispatch: | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Récupérer le dépôt Git | |
uses: actions/checkout@v3 | |
- name: Installer sshpass et rsync | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y sshpass rsync | |
- name: Récupérer et commit les modifications sur la map | |
env: | |
SFTP_IP: ${{ secrets.SFTP_IP }} | |
SFTP_PORT: ${{ secrets.SFTP_PORT }} | |
SFTP_USERNAME: ${{ secrets.SFTP_USER }} | |
SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }} | |
LOCAL_PATH: region/ | |
REMOTE_PATH: /world/region | |
run: | | |
# Ajout de la clé SSH à known_hosts | |
mkdir ~/.ssh | |
touch ~/.ssh/known_hosts | |
ssh-keyscan -H $SFTP_IP >> ~/.ssh/known_hosts | |
# Synchronisation des fichiers du serveur SFTP vers le dossier local | |
sshpass -p $SFTP_PASSWORD rsync -az --port $SFTP_PORT --delete $SFTP_USERNAME@$SFTP_IP:$REMOTE_PATH $LOCAL_PATH | |
# Vérification des différences entre les fichiers locaux et du repo Git | |
# et commit si nécessaire | |
git diff --exit-code --quiet $LOCAL_PATH || \ | |
(git add $LOCAL_PATH && git commit -m "Synchronisation de la carte" && git push) |