<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Farhang Darzi</title>
    <description>The latest articles on DEV Community by Farhang Darzi (@farhang).</description>
    <link>https://dev.to/farhang</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F155768%2Ff164df08-75ea-49e9-9253-7ea018cbab68.jpg</url>
      <title>DEV Community: Farhang Darzi</title>
      <link>https://dev.to/farhang</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/farhang"/>
    <language>en</language>
    <item>
      <title>Publish your Angular app to Github Pages using Travis CI</title>
      <dc:creator>Farhang Darzi</dc:creator>
      <pubDate>Sat, 28 Sep 2019 10:33:14 +0000</pubDate>
      <link>https://dev.to/farhang/publish-your-angular-app-to-github-pages-using-travis-ci-1dg3</link>
      <guid>https://dev.to/farhang/publish-your-angular-app-to-github-pages-using-travis-ci-1dg3</guid>
      <description>&lt;p&gt;It is a good idea to deploy your Angular application with latest changes on github pages automatically. Travis CI is an appropriate tool to do that.&lt;/p&gt;

&lt;p&gt;OK, let’s start ☺&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Prerequisites&lt;/b&gt;&lt;br&gt;
Node.js ≥ 10&lt;br&gt;
Angular CLI&lt;/p&gt;

&lt;p&gt;To get strarted, simply create an Angular project on your local computer using commands below:&lt;/p&gt;

&lt;pre&gt;
ng new angular-github-pages-travis // no diffrences between having routing or not
cd angular-github-pages-travis
&lt;/pre&gt;




&lt;p&gt;Then, create a repository on Github:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wN3p9jyB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lhev4w76ww1y1oej34fc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wN3p9jyB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lhev4w76ww1y1oej34fc.png" title="Create a repo on Github"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Add the remote repositoy to your local computer and push the changes using following commands:&lt;/p&gt;

&lt;pre&gt;
git remote add origin git@github.com:YOUR_USER_NAME/YOUR_REPOSITORY_NAME.git
git push -u origin master
&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T20_yB3h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/b9a3rf40tzntsq0xvri7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T20_yB3h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/b9a3rf40tzntsq0xvri7.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Signup to &lt;a href="https://travis-ci.org" title="Travis CI"&gt;Travis CI&lt;/a&gt; and turn on your repository to be synced with it.&lt;/p&gt;

&lt;p&gt;Switch to setting of your active repository in Travis CI panel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hFGNuZWp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r5b1cvi1ljw25tfq7xha.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hFGNuZWp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r5b1cvi1ljw25tfq7xha.png" title="Travis CI - setting page"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Turn on the repository to start being synced with Travis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c6uMC2fq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/pkk3zja161lr4yi4vng1.png" class="article-body-image-wrapper"&gt;&lt;img title="Travis CI - Turn on the repository" src="https://res.cloudinary.com/practicaldev/image/fetch/s--c6uMC2fq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/pkk3zja161lr4yi4vng1.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Create an enviroment variable named “GITHUB_TOKEN” then paste your github token value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UVnf6VAZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/uittgfbe22jajncsonbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UVnf6VAZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/uittgfbe22jajncsonbe.png" title="Travis CI - Create an enviroment variable"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your don’t have Github token you can create one using this link:&lt;br&gt;
&lt;a href="https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line" title="Getting Github token"&gt;&lt;/a&gt;&lt;a href="https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line"&gt;https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Now go back to the local project and create “.travis.yml” file in the project root. Then copy the code below and paste it to the file:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;q&gt;Click on the link below to find out more information about the travis CI commands: &lt;a href="https://docs.travis-ci.com/user/apps/"&gt;&lt;/a&gt;&lt;a href="https://docs.travis-ci.com/user/apps/"&gt;https://docs.travis-ci.com/user/apps/&lt;/a&gt;&lt;/q&gt;&lt;/p&gt;




&lt;p&gt;Now in your local repository Add "--prod" flag to package.json file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pvyxw9w4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/b2rbjyj8wpypxmctljyl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pvyxw9w4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/b2rbjyj8wpypxmctljyl.png" title="Add --prod flag to package.json"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;After that, add baseHref to angular.json.&lt;/p&gt;

&lt;pre&gt;"baseHref": "https://YOUR_USER_NAME.github.io/YOUR_REPOSITORY_NAME/",&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vH-80k53--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/d5wm7qkyo84n0sm39crk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vH-80k53--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/d5wm7qkyo84n0sm39crk.png" title="Adding baseHref to angular.json"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Commit and push your changes.&lt;/p&gt;




&lt;p&gt;If you get succeeded, just visit the github pages of your github project, you can follow the build status in Travis CI using the following url :&lt;br&gt;
&lt;a href="https://YOUR_USER_NAME.github.io/YOUR_REPOSITORY_NAME/"&gt;&lt;/a&gt;&lt;a href="https://YOUR_USER_NAME.github.io/YOUR_REPOSITORY_NAME/"&gt;https://YOUR_USER_NAME.github.io/YOUR_REPOSITORY_NAME/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations 👍&lt;/p&gt;

&lt;p&gt;Please leave a comment If you have any question or issue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/farhang/angular-github-pages-travis"&gt; Github (sample code) &lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>github</category>
      <category>travis</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
