There is an application generated using create-react-app
. Need to deploy it on imtqy.com.
The problem is that Github Pages only works with static code and Jekyll.
Of course, it's enough for us to simply compile the application somewhere else and then upload it on imtqy.com
Travis CI was the perfect match for this task. as it turned out, he has the possibility of deploying a github out of the box (no need to quit and write complex scripts for this).
I started two repositories:
yarn build
)git rm -r .
- this will remove all files (cap).cp -r build/ ../compiled-app
)git add .
git commit
git push
language: node_js node_js: - '9.11' cache: directories: - "node_modules" script: - yarn test - yarn build - echo my-custom-domain.ru > build/CNAME deploy: provider: pages github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable committer-from-gh: true skip-cleanup: true keep-history: true local-dir: build repo: Yourname/compiled-app target-branch: master on: branch: master
Explanations:
github-token
- it needs to be generated in github settings. Read more here . The environment variable must be set in the project settings on travis-ci.comkeep-history
- without this option, the repository will essentially be created every time anew (push -f) and it will be impossible to track the history. With him, everything will be just about the same (approximately as I described it in the "manual deployment" section).local-dir
- after the build has completed, the trace needs to know what to save to the repository. Without this option, it will save the entire current code, and with it the specific folder. Keeping the project completely can be useful if you do not want to use two repositories, like me, but using the docs/
folder or a separate branch not related to the code.repo
is exactly the option that allows the deployment to another repository. Do not forget to specify the owner.target-branch
- to which branch the push should occur. By default, gh-pages
, I use master, because I have a separate repository.Personally, I ran into only one problem.
If the custom domain is not used, the site will be located at yourname.imtqy.com/projectname
, and thus the absolute paths (for example, /favicon.ico
) would /favicon.ico
. I did not think about the decision, because I use a separate domain.
I love imtqy.com and have long wanted to pick it up, is it possible to deploy compiled sites other than Jekyll. It was very nice to find out that they already thought about this in travis-ci.
I also thought today that perhaps it would be better not to create a separate repository, but simply to use a separate branch. In order not to clutter up my list of repositories, which is already full of rubbish. Well, as they say, c'est la vie
I play the game Heroes of the Storm and wanted to make a small application that would make it easier for me to select a character during the draft. If shorter: filter characters by their features.
Source: https://habr.com/ru/post/359368/
All Articles