Updating code on Digital Ocean via GitHub - django

I have a Django app on Digital Ocean https://chicagocreativesnetwork.com/ which was uploaded via GitHub.
I need to make some changes to the CSS and HTML for this app, which I am doing locally and pushing to my GitHub repository.
How do I get the pushed GitHub updates into my Digital Ocean app?

How was the app uploaded to your Digital Ocean droplet exactly? Was the repo cloned or forked to the droplet?
Read the Caution at the end first
You could always go into your droplet console move to the directory where your project is in. Then do:
git status (to see the state of your repo)
then do git fetch (to fetch the changes from your origin to your droplet repo)
do a git status again (to see how many steps your droplet is behind your remote
repo)
if you see everything is ok and it says you are '1 commit behind master'(if you are changing for the first time after deployment)
Go ahead and git pull (with github username and personal access token as password)
do a final git status it should now say 'you are up-to date with remote'
CAUTION - do not git push anything from your droplet console into your remote repo even if git status shows files ready to be staged and committed in red.
These files are local to the droplet repo and should stay as they are. Any change you make should come from -
Local changes pushed to your remote repository
Going into your droplet console and Pulling the changes into your droplet repository
The workflow is detailed more clearly in the following comment:
https://stackoverflow.com/a/42001608/2155469

Related

Updated website from git but changes not appearing

I have hosted a site on an AWS EC2 instance almost 1 year ago. now I am facing an issue with the update of the website. when I commit and push the changes in my git repo. and then I open the ec2 server and try to pull my code it successfully commits the changes but no changes appear on the site or the site doesn't update.
I have already changed the access token of the git repo. and so many times I have rebooted the instance many times but it doesn't worked for me.

Automatic scheduled git pulls on a GCP server running a flask website

I had a few questions about automatic git pulls on a remote server. I am aware there are several questions like this, but I wasn't sure what steps to take exactly, and I don't want to mess up my current setup with a mistake :/
To wit, the environment is on a Google Cloud VM. I am running a flask-based website that renders each page with the render_template() function.
The website resides inside its git folder, i.e. I never set up a bare repo and copied stuff. When I set it up a couple years ago, I just did git clone repo-url, then inside the repo directory, did flask run. Then I set up nginx to connect to the site's socket created with uwsgi inside the repo directory.
--
It has been working fine. I make changes locally to the content, push to github, then log in to the VM, and perform a git pull.
I want to do this automatically. I tried adding a cron job to do this, where the job basically ran a script, and the script did the git pull. Script content was:
cd /repo
git pull
Running the script in the server worked, but cron never managed to do the pull.
--
I have been reading about web hooks, and there is a bunch of stuff about post-receive hooks, post-update hooks, and making bare repos. At this point, I am embarrassed to say I have no idea what I should be doing.
Any help is greatly appreciated.
Another option would be to consider a GitHub Action, which, from GitHub, could interract with your Google cloud VM.
For example, actions-hub/gcloud.
- uses: actions-hub/gcloud#master
env:
PROJECT_ID: test
APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
with:
args: cp your-file.txt gs://your-bucket/
cli: gsutil

django digital ocean git

I have set up my python, virtualenv, django environment in my digital ocean Ubuntu droplet. I have also set up SSH access to be able to deploy using git. I have set a remote url, so to push I just use "git remote live master". I have used git webhooks to push remotely. Since I used git init --bare for my remote repo, I cannot see the source code, I just see the hooks folders, etc.
The only issue is after pushing to the remote repository, how do I connect that repository to my django environment so that I can run it, access those source codes, so that I can do "python manage.py runserver"? I am a beginner to webhosting automatic deployment using git and django, I do appreciate your help.

Deploy Django App on Azure: only displays default app, even after deployment

I am trying to deploy a webapp to Azure. I am following these directions https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-create-deploy-django-app/
First step, I created a webapp (Django) on the portal.
Then it says to follow the directions to configure Continuous deployment using GIT in Azure App Service. This should apparently lead to my having a local directory of Django files. https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/
So I follow those directions, installing Git, creating a local repository, adding a webpage, enabling web app repository, deploying.
The webportal now shows that I have deployed ('active' deployment). However, when I go to the web app url, what's showing is NOT what I deployed, but rather what I guess is the default Django app with its urls (login, logout, contacts).
So then I create an actual Django app in my local directory (instead of the static index.html from the directions). I commit and push it to Azure. It shows as being deployed.
The result is the same as before: the default web app is showing.
So what I'm missing is the connection between my local repository and what's actually showing. Is there some way to pull the Azure default app into my local repository? (Once it's there, I'll be able to change it as I see fit.)
Things are working as expected, but you ended up overwriting the Django app in your first the Git commit. The Continuous Deployment instructions as written are generic to any deployment, even a blank Web App.
So what I'm missing is the connection between my local repository and what's actually showing. Is there some way to pull the Azure default app into my local repository? (Once it's there, I'll be able to change it as I see fit.)
All you need to do is git clone your repo after you've initialized your local Git repo on the Azure Web App. You've already gone through most of these steps, but I'll include them here for others who may be looking for this answer.
After you create the Django Web App from the Azure Marketplace/Gallery, scroll down to set up continuous deployment.
Choose Local Git repo.
Notice that you now have a Git Clone URL in both your Quickstart Essentials info and under All Settings >> Properties. Go ahead and copy this URL.
If you haven't already done so, you may need to set or reset your Deployment Credentials. You'll find this under All Settings. This will be your Git & FTP credentials. Note that this is actually the credentials for your Microsoft Account, not just this one Web App.
You already have Git installed from your first attempt. You should now be able to navigate to the folder you want to clone the repo into and run:
git clone <your_git_clone_url>
After you type in your password, you'll have a cloned repo of the Django Web App on your local system. cd into the directory and start working from there. Once you have changes, git add ., git commit, and git push them back to the repo in Azure to see your changes there.

Repo from heroku to github

I'm kind of new in this of heroku and github, but what I want to do is put a Django application in heroku to my github account. How can I do that from console or something?
You have a local git repository of your code that you pushed to heroku. Now you just got to http://github.com (create an account if you haven't yet) and a repository for your project. You will then get the instructions to push your existing code to the newly created repo.