Maxime Dupré
Maxime Dupré

Reputation: 5757

Can you add a build step for github pages deployment?

I would like to use the master branch of my repo as the source for my github page. I need a build step (ng build --prod --aot) to generate the index.html file that would need to be displayed. I also don't want the generated files to be versionned. Is there a way to accomplish that using Github alone or with Travis CI or any other tool?

Upvotes: 4

Views: 1184

Answers (3)

Jos de Jong
Jos de Jong

Reputation: 6819

You can use Deploy To Github Pages to configure a build step before publishing to your Github Pages:

https://github.com/marketplace/actions/deploy-to-github-pages

Basically: you have to configure your project to with github pages, served from the gh-pages branch. Next, you configure a Github Action to perform the build and deploy step using Deploy To Github Pages as described in the docs of the tool.

Upvotes: 0

mhhollomon
mhhollomon

Reputation: 993

You cannot add a step to the build process on the github side. The process that takes your repository and turns it into something servable can only be controlled by the setting on the profile page.

In the end, if the index file is not jekyll, it will be served as is from the repository.

The one thing you can do is have two repositories - one of the "source" and one that is the actual pages that are served. That at least will keep the index.html file out of the source repository.

Upvotes: 1

Laurent S
Laurent S

Reputation: 4326

It looks like the travis deployment system to github pages is exactly what you need:

Deploying to GitHub Pages uses git push --force to overwrite the history on the target branch, so make sure you only deploy to a branch used for that specific purpose, such as gh-pages.

Upvotes: 0

Related Questions