On git @ OSC, use the PUSH hook to access the automatically deployed PHP file under the project through URL every time you push {code ...} after each push. text does have a record, but the code is not updated. You have to manually gitpull it every time. How can this be done? On git @ OSC, use the PUSH hook to access the automatically deployed PHP file under the project through the URL each time you push
Password! = "Xxxxxx") die ("ERROR! "); // Determine the password $ fp = fopen (". /log.txt ", 'A'); $ lastcommit = $ js-> push_data-> commits [count ($ js-> push_data-> commits)-1]; // obtain the final commitif (strstr ($ lastcommit-> message, "release") // This indicates that if the final commit contains "release", it is automatically released. {Exec ('CD/home/xxx/'); // enter the directory exec ("git pull origin master"); // perform git pulling, the premise is that sshfwrite ($ fp ,"!!! ". Date ('Y-m-d H: I: s '). "\ t ". $ lastcommit-> message. "\ t ". $ lastcommit-> author-> name. "\ t ". "Y ". "\ n"); // record} else {fwrite ($ fp, date ('Y-m-d H: I: s '). "\ t ". $ lastcommit-> message. "\ t ". $ lastcommit-> author-> name. "\ t ". "N ". "\ n ");}
After each push, the log. text in the project does have a record, but the code is not updated. You still have to manually run git pull every time. How can this be done?
Reply content:
On git @ OSC, use the PUSH hook to access the automatically deployed PHP file under the project through the URL each time you push
Password! = "Xxxxxx") die ("ERROR! "); // Determine the password $ fp = fopen (". /log.txt ", 'A'); $ lastcommit = $ js-> push_data-> commits [count ($ js-> push_data-> commits)-1]; // obtain the final commitif (strstr ($ lastcommit-> message, "release") // This indicates that if the final commit contains "release", it is automatically released. {Exec ('CD/home/xxx/'); // enter the directory exec ("git pull origin master"); // perform git pulling, the premise is that sshfwrite ($ fp ,"!!! ". Date ('Y-m-d H: I: s '). "\ t ". $ lastcommit-> message. "\ t ". $ lastcommit-> author-> name. "\ t ". "Y ". "\ n"); // record} else {fwrite ($ fp, date ('Y-m-d H: I: s '). "\ t ". $ lastcommit-> message. "\ t ". $ lastcommit-> author-> name. "\ t ". "N ". "\ n ");}
After each push, the log. text in the project does have a record, but the code is not updated. You still have to manually run git pull every time. How can this be done?
Exec ('CD/home/xxx/'); // enter the directory exec ("git pull origin master"); // execute git pulling, provided that ssh is used
Write it together in an exec file. cd will not modify the directory where the parent process is located. In addition, it is best to redirect the output to the file for troubleshooting.