Using .gitignore on Heroku - github

I recently added an extra file that I want hidden (hushed.js). I created a .gitignore file and added hushed.js to it. I tested it out locally, and it works perfectly. Pushed everything up, and now it breaks in Heroku. In the logs, Heroku says it cannot find that file (Error: Cannot find module '../hushed.js').
My Github and Heroku accounts are connected, so I just push to Github, and it automatically gets deployed in Heroku.
I deleted the .gitignore file, and pushed it up. The Heorku app works perfect now, but alas, the hushed.js is visible in Github.
How can I keep that file "hidden" on Github, but still used by Heroku?

You cannot. If the file is not in GitHub, Heroku will not be able to fetch it, as it retrieves the files directly from GitHub.
If this file contains sensitive data that you don't want to see in GitHub, you can use config variables.
You could also auto-generate that file at deploy time by running the generation code on postinstall.

Related

Github pages 404ing on single file

I have a built react app in the docs directory of my project. The project is set to have it's github page source to that directory. All that works fine.
https://pgooch.github.io/find-your-ross/#/
As you can see, it all works, notably the image assets, which are located here.
https://github.com/pgooch/find-your-ross/tree/master/docs/static/media
While all of that works absolutely great, the markdown file in that directory 404's.
https://pgooch.github.io/find-your-ross/static/media/_linked_readme.d73385c3.md
The file appears in the repo as you'd expect (it's at the very bottom of the list). I have; waited more than 8 hours, tried different browsers on different devices, and checked that the permissions were good, confirmed that the file names were cased the same. No difference. This file 404s when viewed directly or fetched (as can be seen by clicking about).
The reason why the _linked_readme.d73385c3.md file is not coming up on GitHub pages is due to Jekyll ignoring the file which has a name starting with an underscore.
If you are not using Jekyll, just add an empty .nojekyll file within the docs folder. You can just create the file and commit it on GitHub UI or create the file on your local machine, commit it and push it to the GitHub repo. Once the file is added within the docs folder, the _linked_readme.d73385c3.md file will come up on your GitHub pages site.
Or if you have the option of renaming your file, just drop the underscore at the beginning of the file and rename it from _linked_readme.d73385c3.md to linked_readme.d73385c3.md.
Reference: GitHub

How to re-connect a local github repository I completely overwrote?

I have a Unity project that I messed up badly, so I downloaded the zip file of the latest repository I pushed to GitHub, deleted the local files, and dumped the content of that zip in place of the old directory. I thought this would be a seamless transition, but now GitHub Desktop is not recognizing these files as a git repository. I don't know why because there are github-specific files in there. I have made significant changes that I need to save. How do I reconnect this repository? Do I want to hit "Clone Again" or will that overwrite what I have locally with what is in the cloud? Again, I want to push what I have locally to the cloud.
For anybody else having this problem, here is what I did:
Save your local repository into a zip file someplace accessible,
like your desktop.
Completely gut your local directory--delete all
contents within the root folder. GitHub Desktop demands a clear folder to clone into.
In GitHub Desktop, where it says it
can't find your repository anymore, click the button that says
"Clone Again". This will download your cloud repository into your
local directory--the opposite of what we wanted, but at least what
comes next will work.
Delete all the cloned files that are NOT files associated with GitHub. This will prevent extraneous files from being left over when you overwrite your project files.
Copy all the non-GitHub-related files from the zip into the renewed directory.
This will restore the link between directories. Now, IT IS POSSIBLE that I deleted an essential GitHub file and did not notice (since there are at least 4 of them), and simply restoring THAT file from the cloud would fix everything. If you become disconnected like I was, I recommend trying that first in case it works and saves you time. Those are the files that get overwritten by GitHub when local files are updated.

openshift nodejs copy written file to repo

I have a nodejs app on openshift an one of the things the app does is write a text file.
Problem is, whenever I update code in the app and deploy it, the text file is gone because the live repo address has changed.
Is there a way using build hooks to get any files saved in a particular folder, add them to my git repo and then deploy the app? I'm not completely clear what I would write in a hook or what to save the hook as so any help would be awesome!
Thank you!
You need to store the file inside of your OPENSHIFT_DATA_DIR so that it will not get over-written each time. You can not copy the file into your git repo on the gear. You might want to try something like the WordPress cartridge does, which is create a symlink (using the deploy action hook) to create a folder in your repo dir that is linked to your OPENSHIFT_DATA_DIR (https://github.com/openshift/wordpress-example/blob/master/.openshift/action_hooks/deploy)

Git push remote work but no changes visible

I am currently facing a little problem with git when pushing to my remote server.
Everything works fine on local server, it commit successfully and so do push to my remote repo. Git show master and git show remote-repo/master show the commits modifications done so everything should normally work.
Still when accessing my website nothing has changed. The files simply haven't changed. The remote repo is a bare one, my app is built with Flask, Gunicorn and I use supervisor to manage it. I tried to change git remote path to a new directory created with copy of my files in it, restart supervisor and gunicorn, restart my server, but nothing changed. What is strange is that first push worked. I'd net on a problem of directory structure or oath, still everything is the same. Except that my files are stores in one more directory than local. But i tried to copy files in the upper directory and it did not change anything.
I am kinda lost now and would be grateful for decades for any help or clues about this problem.
Thanks !!
Still a little confused on your set up. You develop on local and push to a server. Does the server have the bare repo or does the server hosting the website have the bare repo?
When you push to a bare that doesn't mean the working tree has changed since bare is just a bare repo- no working tree. If this is the case you have to follow these steps:
1. push from local to server that contains bare
2. pull from the remote bare location from the production server
(the one that contains the website)
3. restart apache or whatever you have
Hope this helps. Please let me know if I am on the right track.
Ok so i've got it working finally ! To do so i init another --bare repo and created a folder for website files. Then, in the bare repo, add to /hooks folder a post-receive SH/script file to check-out files when push received from bare directory to the one for website files. I edited supervisor conf and nginx one, reloaded and restarted all. it's okay now !

Heroku and Github integration (how to structure the project)

I'm creating a webservice and I want to store the source on github and run the app on heroku. I haven't seen my exact scenario addressed anywhere on the 'net so far, so I'll ask it here:
I want to have the following directory structure:
/project
.git
README <-- project readme file
TODO.otl <-- project outline
... <-- other project-related stuff
/my_rails_app
app
config
...
README <-- rails' readme file
In the above, project corresponds to http://github.com/myuser/project, and my_rails_app is the code that should be pushed to heroku. Do I need a separate branch for the rails app, or is there a simpler way that I'm missing?
I guess my project-related non-rails files could live in my_rails_app, but the rails README already lives there and it seems inconsistent to overwrite that. However, if I leave it, my github page for the rails app will contain the rails readme, which makes no sense.
Also ... I tried just setting it up as described above and running
git push heroku
from the main project folder. Of course, heroku doesn't know I want to deploy the subfolder:
-----> Heroku receiving push
! Heroku push rejected, no Rails or Rack app detected.
Here's a simple solution that may or may not work for you.
Create two projects on GitHub. One project should be just the Rails app (i.e. everything inside the Rails app directory). The other project should be everything outside the Rails app directory.
Add the Rails app project as a git-submodule within the "container" project.
Now you can add Heroku as a remote on the Rails app repository separately and push it to heroku. Heroku will accept the push because it is just a Rails app with the expected directories and files.
A solution for the Heroku situation (not the README file):
If you're using the new Heroku Cedar (I believe it wasn't available when you first asked your question) then your processes (like the rails server process) start up using Foreman. Thus, you can place a Procfile in the root github directory that looks like this:
web: my_rails_app/script/runserver.sh
And then my_rails_app/script/runserver.sh could be a simple
#!/bin/sh
cd my_rails_app
bundle exec rails server -p $PORT
Locally, you should also create a file called .env (note the . at the beginning), which contains
PORT=3000
This file is read by foreman and used to set environment variables so that the port is set when you execute foreman start on your machine (from the root github directory, where the Procfile lies). The Heroku server takes care of the .env file on your dyno. The big advantage is you can set up multiple processes on the dyno that way!
Just overwrite Rails' default README file. There's no reason to keep it around. Put your other project-management-related stuff in the doc directory. While you certainly have valid reasons for wanting to set it up the way you did, you're just creating a headache for yourself by going against convention, and it's probably not worth the benefit.
I would add everything underneath /my_rails_app to the Heroku git repository. Then add GitHub as a remote and add everything underneath /project to the GitHub repository. Then you can push the Rails application to Heroku (from /my_rails_app) and push the full project to GitHub (from /project).