This guide assumes you have a working static website project on your machine integrated with DatoCMS. If that's not your case, you can return to the previous sections of this documentation to see how to properly configure the DatoCMS administrative area and how to integrate DatoCMS with your favorite static website generator.
Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.
Commit the files that you've staged in your local repository.
$ git commit -m 'First commit'
At the top of your GitHub repository's Quick Setup page, click the clipboard icon to copy the remote repository URL. In Terminal, add the URL for the remote repository where your local repository will be pushed.
$ git remote add origin YOUR_GITHUB_REPOSITORY_URL
Now, it's time to push the changes in your local repository to GitHub.
git push -u origin master
Now that your project is up and running on GitHub, let's connect it to Travis.
Sign in to Travis CI with your GitHub account, go to your profile page and activate Travis CI for the repository you want to build.
Reach the TravisCI settings page of your project, and add an environment variable called DATO_API_TOKEN
containing the read-only API token of your DatoCMS administrative area:
You can find the API token in the Admin area > API tokens section:
The next step is to add a .travis.yml
file to your repository. Travis CI uses this file in the root of your repository to learn about your project and how you want your builds to be executed. How this file needs to be structured differs a lot depending on the static website generator you are using. Here we'll show you some examples to get started.
Please refer to the official TravisCI documentation to learn everything regarding how to configure your build and how to properly deploy the actual website to S3.
1language: ruby2script:3 # first dump all the remote content as local files4 - bundle exec dato dump5 # then generate the website6 - bundle exec dato jekyll build7deploy:8 provider: s39 access_key_id: XXX10 secret_access_key: YYY11 bucket: your-bucket12 local_dir: public13 skip_cleanup: true14 acl: public_read
1language: node_js2sudo: required3before_script:4 # download latest version of hugo5 - wget https://github.com/spf13/hugo/releases/download/v0.19/hugo_0.19-64bit.deb6 # install it7 - sudo dpkg -i hugo*.deb8script:9 # first dump all the remote content as local files10 - ./node_modules/.bin/dato dump11 # then generate the website12 - hugo13deploy:14 provider: s315 access_key_id: XXX16 secret_access_key: YYY17 bucket: your-bucket18 local_dir: public19 skip_cleanup: true20 acl: public_read
1language: ruby2script:3 - bundle exec middleman build4deploy:5 provider: s36 access_key_id: XXX7 secret_access_key: YYY8 bucket: your-bucket9 local_dir: build10 skip_cleanup: true11 acl: public_read
1language: node_js2script:3 # first dump all the remote content as local files4 - ./node_modules/.bin/dato dump5 # then generate the website6 - node index.js7deploy:8 provider: s39 access_key_id: XXX10 secret_access_key: YYY11 bucket: your-bucket12 local_dir: build13 skip_cleanup: true14 acl: public_read
There's only one last step needed: connecting DatoCMS to TravisCI, so that everytime one of your editors press the Publish changes button in your administrative area, a new build process (thus a new publication of the final website) gets triggered.
To do so, go to the Admin area > Environments, select TravisCI and follow the instructions to conclude the integration:
When everything is done, confirm the integration pressing the Save Settings button.