TD Workflows can be used with version control tools like Git and continuous integration tools such as Travis CI. In this tutorial, we’ll go through how to set up a Continuous Deployment pipeline using GitHub and Travis CI.
If you have not already done so, create a git repository on GitHub with your workflow project. For more information on how to use Git and GitHub, see the GitHub Bootcamp.
Add a Travis CI configuration file to the project. The file should be named .travis.yml, be in the top directory of the project, and have the following contents. Then commit and push to GitHub.
language: ruby
rvm:
- 2.7.2
script:
- gem install td
- td -e https://api.treasuredata.com -k $TD_API_KEY wf check
- td -e https://api.treasuredata.com -k $TD_API_KEY wf push $WF_PROJECT
branches:
only:
- masterThe configuration specifies that Travis CI should deploy changes on the master branch only. This ensures that changes on other branches and pull requests are not deployed until they are merged to master.
For more information on Travis CI configuration, see the Travis CI documentation.
Go to Travis-ci.com and Sign up with GitHub.
Accept the Authorization of Travis CI. You’ll be redirected to GitHub.
Select the green Activate button, and select the repositories you want to use with Travis CI.
For workflows to be pushed to Treasure Data, you must configure a TD API Key for the project. You can read more about out how to set you TD API key in Travis CI here.
To define variables within your Travis CI project:
From the Repository Settings, make sure you’re logged in.
Navigate to the repository in question.
Choose Settings from the cog menu.
Select Add new variable in the Environment Variables section.
Open the Travis CI dashboard again and locate the workflow repository.
Select the workflow project.
Select Repository Settings. You might need to select the down arrow and select Settings.
Select Environment Variables under Build Settings.
Type
TD_API_KEYinto the Name field and your TD API key in the Value field.Select Save variables.
- Open the Travis CI dashboard again and select the failed workflow project build.
TravisCI should now successfully push your workflow to Treasure Data and executes as a workflow every time you push a change to GitHub.