Set up auto-deploy on AWS
-
From the terminal, enter ssh-keygen at the command line.
ssh-keygen -
Press the Enter key to accept the default location.
-
Enter and re-enter a passphrase when prompted.
-
Run the following code
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts -
Copy the key that’s been created
cat ~/.ssh/id_rsa.pub -
Copy contents
-
Add key to bitbucket
Settings > Access keys >Add key
-
Paste key
-
Create webhook in bitbucket
Webhooks > Add webhook
Title: Auto Deploy
URL: http://bayroom.pinkpanda.com.au/deploy.php
Active YES
SSL NO
Repository push YESSAVE
-
Create php file deploy.php in root of website
-
Add the following code to deploy.php
$output=shell_exec('cd /bitnami/wordpress/wp-content/themes/bayroom && sudo -u bitnami git pull 2>&1');
file_put_contents('deploy.log', date('m/d/Y h:i:s a') . " - " . $output . "\n", FILE_APPEND);
(old bitnami instance url - /opt/bitnami/apps/wordpress/htdocs/wp-content/themes/bayroom) -
If you have an existing theme, delete it.
-
Clone your theme using SSH not HTTPS
git clone git@bitbucket.org:pinkpandaau/cc-ajax-2019.git *FOLDERNAME* -
Install sudoers
sudo apt-get install sudo -
Add the following items to sudoers via sudo nano /etc/sudoers
daemon ALL=(ALL:ALL) NOPASSWD: /usr/bin/git
daemon ALL = NOPASSWD: /usr/bin/git -
If it’s throwing an error, add the following line
daemon ALL=(ALL) NOPASSWD: ALL