I am trying to automatically deploy code to a shared hosting account, using the Git™ Version Control feature of CPANEL.
I can see from the history of the remote repository, that my code does reach the remote. and I can see the message generated by the post-receive hook of the remote repository.
It says,
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 302 bytes | 302.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Recieved update on checked-out branch, queueing deployment.
remote: ---
remote: apiversion: 3
remote: func: create
remote: module: VersionControlDeployment
remote: result:
remote: data: ~
remote: errors: ~
remote: messages: ~
remote: metadata: {}
remote:
remote: status: 1
remote: warnings: ~
To ssh://my-domain.com/home/my-username/cicd
7e20639..8ebdfb5 HEAD -> master
However, the deployment of files is not happening to the desired location.
Contents of my .cpanel.yml file are as below
---
deployment:
tasks:
- export DEPLOYPATH=/home/my-username/public_html/cicd.my-domain.com/
- /bin/cp index.html $DEPLOYPATH
Contents of my post receive hook are
#!/bin/sh
# post-receive Copyright 2018 cPanel, Inc.
# All rights reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
branch=$(/usr/local/cpanel/3rdparty/bin/git branch | awk '$1 == "*"{print $2}')
while read oldrev newrev ref
do
if [ "x$ref" == "xrefs/heads/$branch" ]
then
echo "Recieved update on checked-out branch, queueing deployment."
(cd .. ; /usr/bin/uapi VersionControlDeployment create repository_root=$PWD)
fi
done < /dev/stdin
Cpanel Documentation , says the "create" function will have log in the following location
~/.cpanel/logs/vc_TIMESTAMP_git_deploy.log
but there is no logs/ folder in there.maybe i cant see it because its a shared hosting.
I updated the receive.denyCurrentBranch config item
Updated the git config settings receive.denyCurrentBranch of the remote branch from updateInstead to false. Because otherwise I was getting the following error while pushing.
fatal: bad config value for 'receive.denycurrentbranch' in ./config
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If it will help, my GIT remote version is 2.19.1