📜 ⬆️ ⬇️

Depla webpack applications on imtqy.com using Travis CI

Task


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.


Decision


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:



How is the manual deployment


  1. Compile code ( yarn build )
  2. In the folder of the second repository do git rm -r . - this will remove all files (cap).
  3. Copy the compiled code into the second repository ( cp -r build/ ../compiled-app )
  4. git add .
  5. git commit
  6. git push

.travis.yml


 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:



Possible problems


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.


Documentation



Conclusion


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


Offtop for those who are interested in exactly what I was doing


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.


Here is the main repository .


Compiled code repository


')

Source: https://habr.com/ru/post/359368/


All Articles