CICD your Tableau Dashboard with Github Actions
Commit and push your .twb (Tableau Workbooks) files confidently
Tableau is a data visualization tool used in the Business Intelligence industry that is mainly used by our Data Team to create an Analysis and Dashboard.
When creating/developing a Dashboard, Tableau users usually connect to/extract data with Data Sources, create views and analysis in Workbook, and publish it from Tableau Dekstop to Tableau Server to reach their audiences.
And under the hood, publishing Workbook is done by submitting .twb or .twbx files by Tableau Desktop to Tableau Server.
Most Tableau users use .twbx for offline and simple Analysis/Dashboard but when it comes to Analyzing/Dashboard with a large set of data .twb is far more preferable since it only contains Tableau’s instructions and connection information (not actual data) that make it more compact and modular than .twbx more info about .twb and .twbx here.
But this whole process rarely involves any audience or peer’s feedback and often doesn’t cover the requirements for controls and QA that software development follows.
So I create a new flow for Tableau Users that want to improve their Workbook developments process, by adding an extra step, Dashboard Promotion Flow.
With this new flow, every dashboard (except user sandbox and one-time dashboard) must be added to the repository, go through the Staging, and get reviewed before gets published to the Production.
Implementing this flow follows most data platform developments processes do.
Define what it needs
Other than the .twb file, another info is needed for publishing Workbook, like the name of Workbook in the Tableau Server and to what project Workbook published, so I create a metadata file
workbooks.yml that stores those configurations.
Create a python script that publishes .twb file
The next step is creating a python script that publishes any .twb file to any project in the tableau server using the given parameters (name, project_id, source file). this process is quite simple just utilize this library tableau.github.io/server-client-python
To which Tableau Project this new Workbook will be placed?
Since the tableau project name is not unique, publishing is done by simply pushing the .twb file to some project_id in Tableau Server.
But a new question raises, tableau users, don’t know what is the id of the project that they are targeting, and it’s simply not a good idea referring some Workbooks with looks like some random string (Tableau use UUID as project_id). With that consideration, I use the project path as a reference to the target project when publishing a Workbook (ex: Company Workbook/Company - Approved Workbook/Dashboard/Film).
Apparently, tableau project properties only store project_id and parent_project_id, not project path and there is no API/Library that I know that handles this type of use case (getting project_path from a given Tableau Project), so I create a helper function for that.
With the parse_projects_to_tree() function, I’m parsing all tableau projects into a tree data structure.
I’m using this treelib https://treelib.readthedocs.io/, as it covers my usage scenario, you can use other libraries that you prefer or maybe create your own tree module :)
This is done by using project_id and parent_project_id properties as a Child Node and a Parent Node, also I’m adding project_name as a Node Payload.
by defining all projects into a tree I can easily retrieve project_id based on project path, simply matching given project_path with Tree Project Structure by traversing the tree based on given candidate nodes.
Add some features….
After the main functionality has been done it’s time to add some features that make Workbook deployments easier.
get_addmodified_files() for getting all .twb files that change on the current PR and, coment_pr() that will send comments to current PR to notify the user when Workbook is published.
These are just the initial features that came to mind, there are more features to comes based on user feedback and “still in coding”, like adding publishing option (Sheets as a tab that transform views as a tab in Tableau Server, publish specific views to only shows selected views in a published Workbooks).
Wrap things up
I wrap my Tableau Workbook Deployments Project into GitHub Actions, using Github Actions to follow the Infrastructure-as-Code principle and have great integration with Github making it easier to use, for this action I set some arguments and environment variables that needed, like
workbook_dir to specify Workbook directory on the repository,
env to change target environments, and
repo_token that hold access token information.
I’m also submitting this GitHub Actions to the GitHub Marketplace if you want to use it github.com/marketplace/actions/tableau-workbook-action
Integrate it with Github
The final step is to integrate newly created Github Actions into GitHub Workflow. Both staging and production workflows.
Staging workflows can be triggered when PR to master is opened and file changes are detected in the directory
And for Production workflows triggered when PR to master is closed and merged.
This sample Workbook result is based on configurations from
workbooks.yml that is published by Tableau Workbook Action triggered from
With this new flow, each Dashboard will be tested and get reviewed first before being published to their audiences, and different drafts and versions will be tracked and managed well.
An (automated) Dashboard deployment is a new concept and can be implemented in various forms. This specific approach is taken when I need to improve Tableau Workbook deployments through GitHub in a simple way, and there might be some improvement that needs to be made or… another approach that is worth exploring.
Thanks for Reading!
If you like this post, you can give my newly published Github Actions a try or you can just share this article so people can find it too. Thank You.