1 parent
ce8bb3dec6
commit
0aec7f3ed5
1 file changed
+16
-7
@@ -33,8 +33,6 @@ jobs:
|
||||
env:
|
||||
SITE_URL: ${{ vars.PREPROD_URL || 'https://preprod.marcillacsante.fr' }}
|
||||
DEPLOY_PATH: ${{ vars.PREPROD_PATH || 'preprod/' }}
|
||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||
SSH_USER: ${{ secrets.SSH_USER }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -43,6 +41,8 @@ jobs:
|
||||
|
||||
- name: Connexion SSH
|
||||
env:
|
||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||
SSH_USER: ${{ secrets.SSH_USER }}
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
|
||||
run: |
|
||||
@@ -52,15 +52,26 @@ jobs:
|
||||
printf '%s\n' "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
||||
chmod 600 ~/.ssh/id_deploy
|
||||
|
||||
# Hôte « ovh » : espaces et retours à la ligne collés dans les secrets retirés.
|
||||
host=$(printf '%s' "$SSH_HOST" | tr -d '[:space:]')
|
||||
user=$(printf '%s' "$SSH_USER" | tr -d '[:space:]')
|
||||
printf 'Host ovh\n HostName %s\n User %s\n IdentityFile ~/.ssh/id_deploy\n BatchMode yes\n' \
|
||||
"$host" "$user" > ~/.ssh/config
|
||||
if ! getent hosts "$host" > /dev/null; then
|
||||
echo "SSH_HOST introuvable dans le DNS (${#host} caractères, attendu : ssh.clusterXXX.hosting.ovh.net)"
|
||||
exit 1
|
||||
fi
|
||||
ssh ovh true
|
||||
|
||||
# Le fichier de mots de passe est hors du dossier publié : rsync --delete n'y touche pas.
|
||||
- name: Mot de passe et non-indexation
|
||||
env:
|
||||
PREPROD_USER: ${{ secrets.PREPROD_USER }}
|
||||
PREPROD_PASSWORD: ${{ secrets.PREPROD_PASSWORD }}
|
||||
run: |
|
||||
remote_home=$(ssh -i ~/.ssh/id_deploy "$SSH_USER@$SSH_HOST" 'echo $HOME')
|
||||
remote_home=$(ssh ovh 'echo $HOME')
|
||||
printf '%s:%s\n' "$PREPROD_USER" "$(openssl passwd -apr1 "$PREPROD_PASSWORD")" \
|
||||
| ssh -i ~/.ssh/id_deploy "$SSH_USER@$SSH_HOST" 'cat > ~/.htpasswd-preprod && chmod 644 ~/.htpasswd-preprod'
|
||||
| ssh ovh 'cat > ~/.htpasswd-preprod && chmod 644 ~/.htpasswd-preprod'
|
||||
|
||||
{
|
||||
echo '# Préproduction : accès par mot de passe (HTTP n'"'"'est autorisé que pour la redirection vers HTTPS)'
|
||||
@@ -82,6 +93,4 @@ jobs:
|
||||
|
||||
- name: Envoi sur OVH
|
||||
run: |
|
||||
rsync -rlz --delete --checksum \
|
||||
-e "ssh -i ~/.ssh/id_deploy" \
|
||||
dist/ "$SSH_USER@$SSH_HOST:$DEPLOY_PATH"
|
||||
rsync -rlz --delete --checksum dist/ "ovh:$DEPLOY_PATH"
|
||||
Reference in new issue
Block a user