Automatic pushing to Dreamhost from Github via Workflows - github

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?

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.

Related

How to create a CI/CD pipeline for deployment on physical server

I have multiple servers installed at client site. I can access all of them via anydesk. I have python project running on them. All of the source code is in azure devops. I want to create a CI CD pipeline so that whenever we merge pull request to main branch, it should automatically be deployed on client's server.
Previously, I have worked on many web API's which was deployed on azure. We had branches created for each client and whenever we merge changes into those clients branch, it automatically used to start deployment on API as our repo and branch was linked to web API.
To deploy the new code changes on server, I have to follow manual way of first logging into the client server via anydesk and then perform the git pull to pull the required changes. This is very manual thing and we sometime do mistake in it. I am looking for a way to connect the client server with the branch of the repo so that once we merge our changes to that branch, it should automatically deploy the changes. Is there any way we can do it? Is there any tool/service available for this. All the client server are Ubuntu machines. Please give some suggestions. Thanks

is there a way to mirror digital oceans unto a new github repo without using the old github repo(if it exists)

a client of mine has deployed a project he was using GoDaddy then migrated to digital oceans, I want his Github repo but the one on go daddy is outdated and unusable, the DevOps that did the migrations is not responding, so I was thinking if there is a way to clone/mirror from a digital oceans droplet unto a new github repo
Perhap you could use hub.
If you can ssh into the droplet, you just need to cd into the repo, install hub on the droplet, change the origin url to the one you want, and then run hub create. Don't forget to add the droplet's public ssh key to your github to allow hub to access it.

Can a private github repo be synced with pythonaywhere

I want to sync a Django project with pythonanywhere. But the Django repo is private is it possible to do so. So, that the deployment is up to date with the repo.
Yes, it is possible. You could set ssh key-pair on your PythonAnywhere account and add it to your GitHub account. Then pull your code on the PythonAnywhere side and re-load your web app.
You could also automate the whole process. See the tutorial: https://blog.pythonanywhere.com/191/

Make private changes on Github repo before deploy?

On GitHub sadly, a private repo is for premium users, and i uploaded a repo, but it has lot of login third party, and i want to make those login information private, and i have a MongoHQ connection, and want to make the database private, to deploy it on CloudControl.
How CloudControl and Heroku work, is that by taking the file AFTER the clone on disk or the clone is only 'temporary' file, and they take the one hosted on Github?
There is no need to have any credentials in the repository. It's actually highly discouraged to do so. The recommended way is to have your code read the credentials from the environment.
Refer to the Add-on credential section in the documentation for more details: https://www.cloudcontrol.com/dev-center/Platform%20Documentation#add-on-credentials

How to automate sync between a Github repository and Openshift?

What is the best way to automate syn between Github repository and Openshift ?
I found this documentation in openshift : https://www.openshift.com/forums/openshift/how-to-keep-a-github-repository-and-an-openshift-repository-in-sync For manually doing a syncrhonisation.
I guess the first question is why you want to automate it? What do you want to achieve? In many cases a manual push to Openshift and GitHub might be preferable.
However, let's explore some possibilities:
Configure a git remote with multiple urls and then just git push all. See also Able to push to all git remotes with the one command?
Use a GitHub Webhook - https://developer.github.com/webhooks/creating/. GutHub will then send a HTTP request to a given URL on each push. You can then setup something on your openshift gear which listens to the request and if it receives one pulls from GitHub. you might then need to restart the app via ctl_app (see https://www.openshift.com/kb/kb-e1055-how-to-restart-an-application)
Last but not least, you could make use of the .openshift/action_hooks/post_deploy deploy hook in OpenShift. I gets triggered after redeploy of your application. In there you should be able to the repo to GitHub as well.
Which approach makes most sense will depend on your use case.