Building static assets into `./doc` folder of Github pages is not working - github

I have been using Github pages with a custom domain putting all assets including index.html in the root folder of the repository.
Setting the project to be deployed using Github pages at first; All went well with the default action; index.html was served and everything was functional.
Now because I'm trying to modularize and clean the project, nothing is left in the root folder except the necessary build configuration files (along with source).
Locally npm run build part of my build process works fine. I can then serve files from docs folder (because Github uses either root or docs folder) my bundle goes to docs; So I also changed that configuration in Github pages:
(The DNS check goes green after seconds.)
So I defined a NodeJS action to replicate my local build process as:
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout#v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
My actions page shows this order:
I assume that build is done before Github pages does its internal configurations.
I also made sure the CNAME file is still there (/docs) after each build.
Is using (/docs) folder fine to serve the static site ? same as root ?
and is my action being run before Github pages comes into place ?
For reference: my site is inaccessible: https://mylinks.space/
The last thing I can thing of is that because the site is served from a different folder, now CNAME file needs time to be propagated (DNS checking).

#jonrsharpe: That was it.
For reference: a solution here is to make another branch, add the folder (not ignored) and push that only folder to that branch, for example "gh-pages" branch.
That's a perfect solution for this particular case. I had to remove the folder again from "main" branch though. You can automate the process of git commands with a script.
This is the process for my case: (docs in .gitignore)
Manuel build locally each time
Then
git add docs
git subtree push --prefix docs origin gh-pages
git rm -r docs && git commit -m "Initial dist subtree commit"
git push

Related

Forking actions/checkout#v2 at organization level to be used repo's github actions

Problem:
Inherently, github actions has no information about the code within the repo it's being run in. To rid that problem, there is the actions/checkout workflow that is the defacto start of most workflows.
Our enterprise account got locked down to only local actions only:
Because of this, we are not able to use the actions/checkout#v2 at the start of our workflow, thus rendering our Github Actions useless.
Proposed Solution
Fork the actions/checkout repo as a submodule of a repo and use that reference in my code like so:
steps:
- uses: <enterprise_name>/<repo_name>/checkout#main
When running this action as a test, I get this error message:
Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under
'/home/runner/work/_actions/<enterprise_name>/<repo_name>/main/checkout'.
Did you forget to run actions/checkout before running your local action?
So my question:
Is there a way to run a forked or local version of actions/checkout? The above example is telling me, I can't run a local version of actions/checkout because I have clone the repo which is ironic error.
You need to push the actions/checkout repo into an internal or public repo on your enterprise. Then update your workflow to reference organization/repo#2 instead.
After forking the actions/checkout repo to my jessehouwing-actions this would result in the following update of the YAML:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout#v3
Would become:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: jessehouwing-actions/checkout#v3
Don't use submodules.

GitHub page shows readme file instead of index.html but works only if mentioned full path to html file

I am new to this and I would really need some help. I am trying to deploy my GitHub page from my GitHub repository. I have set the gh-pages branch as my default, I put the code in there.
The code is in here: https://github.com/MelisaBogdan/melisabogdan.github.io
I tried to check if the website is visible with this link https://melisabogdan.github.io but all I see is the readme file. BUT I can perfectly see it by mentioning the folders https://melisabogdan.github.io/root/index.html
I know that many people managed to have their website visible without mentioning the full path ( by simply typing https://melisabogdan.github.io).
Is there anything I can do? I would really appreciate some help I tried what some other people suggested....
Since this is a NodeJS based site, there are many things that you need to do. Do the following steps to see your portfolio at https://melisabogdan.github.io/ . Basically you need to setup a GitHub action in your repository which runs the NodeJS code & then puts the static HTML/CSS files in your gh-pages branch.
Change your default branch to master by going to your_repo > settings > Branches (on left tab) > Default branch
Create a folder .github (include that dot) in the master branch
create a folder workflows within this folder
create a file deploy.yml inside workflows folder
Put the following code in deploy.yml
name: Build and Deploy
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout#v2.3.1
with:
persist-credentials: false
- name: Install and Build 🔧
run: |
npm install
npm run build
- name: Deploy 🚀
uses: peaceiris/actions-gh-pages#v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
So finally the folder structure should be like:
melisabogdan.github.io/.github/workflows/deploy.yml
Now commit these files to GitHub
Now if you go to the actions tab in your repo, should see an action running. It will take 2-3 mins & then finally, you should be able to see your site at https://melisabogdan.github.io/

Travis-CI will not build a new GitHub Repo

I created a new repo on github and added the .travis.yml file and some sphinx documents but travis won't trigger a build. I can push to another older repository and https://travis-ci.org builds fine. I double checked that the .travis.yml file is exactly like other repositories that do build. I checked github Authorizing OAuth Apps and travis is there.
.travis.yml
language: python
install:
- pip install sphinx sphinx_rtd_theme mock
script:
- sphinx-build -Wv docs/source docs/html
deploy:
# publish docs on push
- provider: pages
skip_cleanup: true
keep-history: false
github_token: $GH_TOKEN
local_dir: docs/html
on:
branch: master
I made a second repo just to make sure I did it correctly.
I follow my instructions for setting up a GitHub, sphinx and travis each time I create a repo.

GitHub Actions : git pull on the server

I have a personal website on a GitHub repo called personal-website and every-time I am making changes locally, I have to SSH into my server (DigitalOcean), go to var/www/personal-website and make a git pull.
I am trying to find a way to pull from the master every-time there is a push into the same branch. I read about GitHub actions and wrote a file on .github/workflows/devops.yml
name: Build and Deploy
on:
push:
branches: master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
GitHub Actions result of Build and Deploy job
On my GitHub Actions page, the job is successful. However, there is no automatic pull request that is done on the server side. How can I fix this?
Make a .sh script and do git pull / git commit / git push

Deploy user Github pages only after Travis tests passed

I'm trying to deploy an User github page only after the execution of all the Travis tests.
However, User pages must be built from the master branch and I need it to be built from the gh-pages if I want Travis to deploy once the tests passed.
The .travis.yml is:
language: node_js
node_js:
- "8.1"
sudo: false
before_install:
- rvm install 2.2.2
- ./tool/before_install.sh
script: ./tool/travis.sh
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN # Set in travis-ci.org dashboard, marked secure
keep-history: true
on:
branch: master
This configuration file works fine when the gh-pages branch is the one the github page is built from, but when I switch my github page to an User page, I can't choose the gh-pages branch anymore, as shown here:
I tried to change the .travis.yml file:
language: node_js
node_js:
- "8.1"
sudo: false
before_install:
- rvm install 2.2.2
- ./tool/before_install.sh
script: ./tool/travis.sh
branches:
only:
- gh-pages
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN # Set in travis-ci.org dashboard, marked secure
keep-history: true
on:
branch: gh-pages
And then to git push on the gh-pages branch instead of the master hoping it will deploy then on the master one such as when I did git push to the master one and it deployed on the gh-pages, but it does not update the master one in this case and so, the modifications are not considered.
And also, when I tried not to use the gh-pages step, the changes were deployed by Github/pages before the end of the Travis tests, so the Github page was updated even if the tests failed.
Is there a way I did not think about to make this works?