<p>You need to add this to your <code>.lektorproject</code> file.</p>
<p>Whenever Travis builds it will automatically throw the end result into the
<code>gh-pages</code> branch and the website updates. We do however still need to
configure the access credentials. We will get to that.</p>
<h2id="enabling-travis">Enabling Travis</h2><p>So now that we have all that configured we need to tell travis to build the
repository. For that just head to your <ahref="https://travis-ci.org/profile"class="ext">Travis-CI Profile</a> and enable the repository. If it does not
show up yet, you can force a sync with the click of a button.</p>
<h2id="access-credentials">Access Credentials</h2><p>So how do you safely provide your credentials? Lektor accepts username and
password for the <code>ghpages+https</code> transport via the <code>LEKTOR_DEPLOY_USERNAME</code>
and <code>LEKTOR_DEPLOY_PASSWORD</code> environment variables. These can be set in the
Travis-CI settings of your repository on travis-ci.org in secret so they are
not stored anywhere else and will not show up in the build output. However one
thing you need to be careful with is that they still give access to your entire
account!</p>
<p>To solve this problem we recommend two things:</p>
<ol>
<li><ahref="https://github.com/settings/tokens"class="ext">Create a personal access token</a>
and use that instead. Just provide the token instead of your password on
sign-in. This makes it easily possible to just revoke that token if
something goes wrong. Note that you only need the <code>repo</code> scope for this
to work. This also works if you have 2FA activated on an account.</li>
<li><ahref="https://developer.github.com/guides/managing-deploy-keys/#machine-users"class="ext">Create a deployment (machine) user</a>.
This allows you to use a user that is exclusively used for just the
purpose of updating the website.</li>
</ol>
<p>Once you have done that travis will start deploying the website on every
commit.</p>
<divclass="admonition admonition-warning"><p>When copy/pasting username and password into travis please ensure that
you do not copy any leading or trailing whitespace with it. This will not
just break the build but also reveal the password in the process. For
more information see <ahref="https://github.com/travis-ci/travis-ci/issues/4139"class="ext">travis-ci#4139</a>.</p></div><h2id="committer-information">Committer Information</h2><p>By default the commits to the <code>gh-pages</code> branch will be authored by a user
named “Lektor Bot”. If you want to override this you can export the
<code>GIT_COMMITTER_NAME</code> and <code>GIT_COMMITTER_EMAIL</code> environment variables and
set them to something else. This is best done in the travis settings.</p>
<h2id="private-repositories">Private Repositories</h2><p>If you are using private repositories you will need the commercial version of
travis. It has the advantage that you can also set up SSH keys on there which
means that authentication becomes easier. For more information see <ahref="https://docs.travis-ci.com/user/private-dependencies/"class="ext">Private
Dependencies</a> in
the Travis CI documentation.</p>
<h2id="speeding-up-builds-with-caching">Speeding up Builds with Caching</h2><p>In the default setting Travis will have to rebuild everything because between
builds it does not cache the build results. You can change this by enabling
caching. Adjust your <code>.travis.yml</code> file to look like this:</p>
Please enable JavaScript to view the <ahref="https://disqus.com/?ref_noscript"
rel="nofollow">comments powered by Disqus.</a>
</noscript>
</div>
</div>
</div>
</div>
</div>
<divclass="bottomsummary">
<divclass="container">
</div>
</div>
<footer>
<divclass="container">
<divclass="row">
<divclass="col-sm-4 icon-bar">
<ahref="https://github.com/lektor/lektor/"title="Lektor on GitHub"
><iclass="fa fa-github"></i></a>
<ahref="https://github.com/lektor/lektor/issues/"title="Report Issues for Lektor"
><iclass="fa fa-bug"></i></a>
<ahref="https://twitter.com/getlektor"title="Find Lektor on Twitter"
><iclass="fa fa-twitter"></i></a>
<ahref="https://gitter.im/lektor/lektor"title="Chat on Gitter"
><iclass="fa fa-comment"></i></a>
<ahref="https://github.com/lektor/lektor-website/tree/master/content/docs/deployment/travisci/contents.lr"title="View source for this page"><iclass="fa fa-code"></i></a>