Skip to content

Instantly share code, notes, and snippets.

@Vitzkrieg
Created November 20, 2025 15:51
Show Gist options
  • Select an option

  • Save Vitzkrieg/c85d3a32788da5ac0a3a7343b6cf1c2e to your computer and use it in GitHub Desktop.

Select an option

Save Vitzkrieg/c85d3a32788da5ac0a3a7343b6cf1c2e to your computer and use it in GitHub Desktop.
.cpanel.yml deploy Git branch based on package.json
---
deployment:
tasks:
- export REPONAME=<repo-name> # folder name of Git repo on server
- export THEMENAME=<theme-name> # folder name of WP theme
- export BACKUPPATH=<path-to-cpanel-bkp>/<theme-name>_$(date +%Y%m%d_%H%M%S) # backup folder with date_time
- export DEPLOYPATH=/home/<account-name>/public_html/wp-content/themes/ # theme folder will be in /dist/
- export PATH=~/.nvm/versions/node/v24.11.0/bin:$PATH # make sure npm path is set
- mkdir -p $BACKUPPATH # create backup folder
- cd /home/ostkznpw/repos/$REPONAME # move into repo folder
- npm install # install dependencies
- npm run dist-build # build the theme
- rm -r $DEPLOYPATH/$THEMENAME # remove current theme folder for a clean install
- /bin/cp -R dist/* $DEPLOYPATH # copy all new files from /dist folder
- npm run dist-clean # delete built /dist folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment