Refactor CI scripts