Skip to content

Instantly share code, notes, and snippets.

@aminrpg
Created February 13, 2023 14:24
Show Gist options
  • Save aminrpg/a084d4c6637b1a4ccc69a6fa81a33d1b to your computer and use it in GitHub Desktop.
Save aminrpg/a084d4c6637b1a4ccc69a6fa81a33d1b to your computer and use it in GitHub Desktop.
---
deployment:
tasks:
# NOTE: public_html on cPanel must not be removed or renamed.
# This folder has owner USER:nobody, and the USER user does not have
# access to change owner. So this folder must stay as-is to keep the nobody
# group, which is critical to the site working. A new folder won't work.
- export DEPLOYPATH=/home/USER/public_html
- export REPOPATH=/home/USER/repositories/PROJECT
# Remove previous old files, if any.
- /bin/rm -Rf ${DEPLOYPATH}_old
# Copy old site files to another directory.
- /bin/cp -R ${DEPLOYPATH} ${DEPLOYPATH}_old
# Sync repository files to the deploy target path, excluding .git folder.
# --delete-after will remove deleted files and folders after syncing.
- /bin/rsync -aP --exclude '.git' --exclude '.well-known' ${REPOPATH}/ ${DEPLOYPATH} --delete-after
# Set correct permissions.
- /bin/chmod 755 ${DEPLOYPATH}
- /bin/find ${DEPLOYPATH} -type d -exec /bin/chmod 755 '{}' \;
- /bin/find ${DEPLOYPATH} -type f -exec /bin/chmod 644 '{}' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment