Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic pushing to Dreamhost from Github via Workflows

Recently transitioned hosting my website to Dreamhost from Netlify in order to host a dynamic site. One thing I miss is the ability to automatically deploy from Github to the hosting service when changes are detected in my repo.

I've found tutorials for pushing to Github from my Dreamhost server, but not the other way around. I have multiple people working on this website, and my hope is to do this centrall via Github instead of manually pushing to both Github and the Dreamhost server thru the command line.

My assumption is that to ssh to Dreamhost I need a public key from my client to store on the Dreamhost server. I don't know if this is possible to generate a public key from Github (related to the workflow), but if it is how I would I do it? The other option is to store the ssh credentials with Github repo secrets to connect, but I feel this isn't best practice.

How would I go about pushing my Github repo to my Dreamhost server automatically after changes to main?

like image 463
cameronpoe Avatar asked Jan 24 '26 16:01

cameronpoe


1 Answers

Two different gists suggest the same approach.

  • Create a bare repo on the DreamHost server
  • push to it
  • have a post-receive hook doing the git restore in the target folder (on the same server) where the actual site is deployed

See "How to Git Push to a Server Machine without having to ssh on to that machine every time?"

What remains for your GitHub Action is, as describe in Deploying to a server via SSH and Rsync in a Github Action, to use a dedicated SSH key, whose private key is registered in GitHub secrets.

like image 142
VonC Avatar answered Jan 26 '26 16:01

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!