apt install -y nginx rsync - Add the
githubuser:
adduser --disabled-password --gecos "" --home /home/github github- Add
githubuser to thewww-datagroup created bynginx:
usermod -g www-data github- Generate a public and private SSH keys, add the public key to the
/home/github/.ssh/authorized_keysfile. - Add a
DEPLOY_KEYSecret in Github which contains thegithubuser's private key. - Set proper permissions:
chown -R github:www-data /home/github/.ssh
chown -R www-data:www-data /var/www/html
chmod -R 770 /var/www/html-
Put the
deploy.ymlworkflow in the.github/workflowsdir at the root of the project. This Github Action is triggered on every merge to themainbranch. -
Change the
<HOST>placeholder in theremote_hostkey to the address of your server (make sure your firewall rules allow ssh access) -
The
buildjob in thedeploy.ymlusesrsyncto upload the contents of thesrc/dir to the destination server at the specifiedremote_path(/var/www/html).