GitHub Pages Custom Domain Settings Gets Reset During new Commit - github-pages

I have a static site generated using Zola and I'm using GitHub Actions to do a build of my static site and publish that into a gh-pages branch of my repository. I have also configured my project to serve via GitHub pages using the gh-pages branch.
The problem I'm facing is that as soon as my GitHub action builds a new version and pushes it to the gh-pages branch, the custom domain setting in the GitHub settings gets reset.
Here is what I do in my GitHub action to build and push to TARGET_BRANCH (gh-pages) branch:
- name: Commit and push to target branch
run: |-
git config --global user.email "workflow-bot#mydomain.com"
git config --global user.name "workflow-bot"
git checkout --orphan $TARGET_BRANCH
rm -rf .github/
mv public ..
rm -rf *
mv ../public/* .
touch .nojekyll
touch README.md
echo 'https://www.bigelectrons.com - SITE GENERATED USING ZOLA' > README.md
git add .
git commit -m "generated using zola build"
git push --set-upstream origin $TARGET_BRANCH --force
Any idea what the problem is and how I could resolve th

I just had to add a CNAME file to my gh-pages branch. For example., in the run command, I had to add these two lines:
touch CNAME
echo 'mydomain.com' > CNAME

I know this is not Zola-related, but I've stumbled upon the same error when using Mkdocs.
The documentation says that you need to create a CNAME file in your docs_dir directory, so that their gh-deploy script can pick that up and copy it at the right place in the gh-pages branch (see that doc here).
For information, using the Github developer settings page to set the custom domain does exactly the same thing, ie. creating a CNAME file at the root of the gh-pages branch.

Related

How do I deploy an Angular 13 application to Git Hub Pages and not get Readme or 404

tldr; I think I need to add a github token. I have a token from github, but I have no idea how to implement it at the stage that I'm at.
I am trying to deploy an angular 13 app to github pages. Right now, it is just the auto-generated app (I haven't added or changed any code at this point). Here are the steps I have taken
Step 1: Create App and make sure it works
ng new <appName>
cd <appName>
ng serve
Step 2: Create a Repo on Github
Step 3: Check if it automatically connected to a repo (and remove if it's not the one we want)
git remote
git remote -v
git remote remove origin
Step 4: Connect to correct Git Repo (replace variables with username and project name)
git remote add origin <https://github.com/USERNAME/PROJECT_NAME.git>
Step 5: Push to Git repo
git branch -m main
git add .
git commit -m "initial commit"
git push -u origin main
Step 6: Hosting
npm install -g gh-pages
ng build --prod --base-href /PROJECT_NAME/ (find project name in angular.json at very bottom
gh-pages -d dist
When I do all of this, it shows that it worked. But then, it just loads a 404 error. After a lot of googling, I think it has something to do with a token. So I went and got the token, but I'm not sure what to do with it.
P.S. already saw Git Hub Pages not Deploying. (404) and it was unhelpful.
The answer was User Error. The code above works and will deploy an app successfully to gitHub pages.
The problem was I was going to https://humanhickory.github.io/ but the ng build --prod --base-href had actually created a new folder which I had to navigate to (so https://humanhickory.github.io//)
Futhermore, I was able to use the token by running gh-pages -d dist a second time. The first time I did it it said "remote: Invalid username or password. Fatal: authentication failed for '....'". However, when I ran the same command a second time, it prompted me to log in. So there's that.

Git submodule failure when building pages with Hugo

I am trying to follow the steps on Deployment as described in the manual of Academic-Hugo. The goal is to upload the Hugo website to GitHub pages.
However the following step fails and I have no clue what the issue could be:
$ git submodule add -f -b master https://github.com/<USERNAME>/<USERNAME>.github.io.git public
Reactivating local git directory for submodule 'public'.
fatal: 'origin/master' is not a commit and a branch 'master' cannot be created from it
Unable to checkout submodule 'public'
The .gitmodules file looks like this (not sure how relevant that is though...):
[submodule "themes/academic"]
path = themes/academic
url = https://github.com/gcushen/hugo-academic.git
[submodule "public"]
path = public
url = https://github.com/<USERNAME>/<USERNAME>.github.io.git
branch = master
While <USERNAME> is my actual username of course.
I am new to Hugo and github pages and would appreciate any pointers on how to resolve this or even where to look for the root of the issue.
I had the same issue. I tried to continue on anyway and it ended up working:
site $ hugo
site $ cd public/
site/public $ git add .
site/public $ git commit -m "initial build"
site/public $ git push # After this, all is well.
I did run a git status prior to pushing, but it had a warning (don't recall the message) and suggested I remove the remote origin. I ignored that too.
Had the same issue today and landed on this site that has some useful info about deleting modules and re-doing the whole thing from start. Hope it might be useful to others as well.

GitHub pages for personal site. How to deploy a folder

If I am using GitHub pages for my personal site, how should manage my source files? I have a simple setup which works.
But I understand I can't using Jekyll plugins with GitHub pages. If I want to use Grunt for example to optimise my images, for a usual app/site, it will produce output in say a dist/public folder, which I will then deploy. But I want to still use GitHub to manage my source files, how should I do it?
Depending of repository kind your using, a User/Organization (UO) site or a Project site (P), sources and pages will be versionned in :
User/Organization - sources : sources, pages: master
Project - sources : master, pages: gh-pages
Note: The pages branch is mandatory, but the sources branch name can be changed.
Setup
Initialize an empty github repository : github.com/userName.github.io for UO or github.com/repositoryName for P
Locally, initialize your local repository :
Go to source folder cd /home/username/www/yoursite or anything you want
git init
git remote add origin git#github.com:userName/userName.github.io.git (UO) or git remote add origin git#github.com:userName/repositoryName.git (P)
git checkout -b sources (UO) or git checkout master (P)
in your .gitignore add your dist/public. As you are currently on master we will ignore it an version it in an other branch
git add -A
git commit -m "base sources". You now have committed your sources.
git push origin sources (UO) or git push origin master (P) push your sources in the appropriate branch
cd dist/public
touch .nojekyll, this file tells gh-pages that there is no need to build a Jekyll site
git init
git remote add origin git#github.com:userName/userName.github.io.git (UO) or git remote add origin git#github.com:userName/repositoryName.git (P)
git checkout master (UO) or git checkout -b gh-pages (P) put this repository on the appropriate branch
your grunt task here
git add -A
git commit -m "first build" commit your site code
git push origin master (UO) or git push origin gh-pages (P)
You now have pushed your code and pages in two different branches. They will now be pushed depending on where you are :
pushing sources
cd yourWorkingDirestory
git add -A
git commit -m "your commit message"
git push origin sources (UO) or git push origin master (P)
pushing pages
cd yourWorkingDirestory/dist/public
git add -A
git commit -m "your commit message"
git push origin master (UO) or git push origin gh-pages (P)

Add an existing origin to a django project and pull the existing repo in it.

I am new to GIT hub version Controlling System.
I am working on a project which i downloaded as zip from GIT hub. It is not a git repository. What i want to do is that I want to make it a git repository and want to pull the existing git repository in it when issuing a git pull command.
I want to create my own Development Branch, develop code on local, push code to github, then do a pull request
Help will be highly appreciated.
Since you don't have any history of your changes to preserve I think your best bet is to clone the repo normally, and then copy your changes into that repository. Your question is a bit sparse on details, but something like the following should work
git clone <git hub project> <new folder on your system>
# maybe you can use a tag here for the SHA
git checkout -b my_branch SHA_THAT_REPRESENTS_YOUR_ZIP_DOWNLOAD
cp -r <your existing directory> <your new git repository>
git status # abort if this step doesn't look right
git add # add all your changed files
git commit # commit your work
git rebase <main dev branch> # catch up

How do I deploy Ember.js app developed with ember-cli on github pages?

I have successfully created a small application using ember-cli. I tried pushing it to gh-pages branch of my github repo but it shows error in browser console
Uncaught ReferenceError: require is not defined
loading of vendor.js and vendor.js files from dist/assets is also failing.
I'm not able to run standalone ember app from dist folder in local machine as well, same errors.
has anyone tried it. if yes how to do it correctly?
Since December 2014 there is also an ember-cli addon for this.
First make sure to have set modulePrefix in config/environment.js to your repo's name on github. E.g., for https://github.com/username/my-cool-repo it should be modulePrefix: 'my-cool-repo'.
Then follow these instructions:
Install the addon.
$ ember install:addon ember-cli-github-pages
Commit the changes made by the addon.
$ git add . && git commit -m "Installed addon ember-cli-github-pages"
Create the gh-pages branch with only the necessary files.
$ git checkout --orphan gh-pages && rm -rf `ls -a | grep -vE '.gitignore|.git|node_modules|bower_components|\.\/|\.\.\/'` && git add . && git commit -m "Initial gh-pages commit"
Switch back to your source branch (most likely master).
$ git checkout master
Build your ember app to the gh-pages branch.
$ ember gh-pages:commit --message "Initial gh-pages release"
Push everything (or at least the gh-pages branch) to github.
(This was different for ember-cli <= 0.1.4 and might change again in the future. Make sure to visit the addon's readme.)
As the comments already say: change the baseUrl in config/environment.js to the name of the GitHub repository you are pushing the app to. For example:
Your GitHub respository is called myEmberApplication and resides in
https://github.com/yourUsername/myEmberApplication.git
then the URL to this project's gh-pages would be
https://yourUsername.github.io/myEmberApplication
So in your case you have to change the baseUrl from / (default) to /myEmberApplication.
The reason why you have to do this is because ember-cli adds the <base> header to your index.html file.