Repository navigation
167 lines (140 loc) · 5.84 KB
/
Copy pathdeploy.yml
File metadata and controls
167 lines (140 loc) · 5.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Deploy Changes
on:
# ALLOW TRIGGERING ACTION MANUALLY
workflow_dispatch:
inputs:
cs_tools_version:
description: "The CS Tools version to target for a manual run."
required: false
type: string
source_environment:
description: "The name of the environment you're deploying TML from."
required: false
type: string
target_environment:
description: "The name of the new environment you're deploying TML to."
required: true
type: string
source_org:
description: "The Org to switch to before performing action."
required: true
type: string
default: Secondry
metadata_types:
description: "The type(s) of TML to export, commad separated."
required: true
type: string
default: ALL
tags:
description: "TML tagged with these name(s), commad separated."
required: false
type: string
directory:
description: "Directory to load TML files from."
required: true
type: string
# AFTER A PULL REQUEST IS MERGED / CLOSED
# pull_request:
# types: [closed]
env:
# CS TOOLS IS COMMAND LINE LIBRARY WRAPPING TS APIS
# https://thoughtspot.github.io/cs_tools/tools/git/
CS_TOOLS_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.cs_tools_version || 'v1.6.1' }}
CS_TOOLS_THOUGHTSPOT__URL: ${{ secrets.PRD_THOUGHTSPOT_URL }}
CS_TOOLS_THOUGHTSPOT__USERNAME: ${{ secrets.PRD_THOUGHTSPOT_USERNAME }}
CS_TOOLS_THOUGHTSPOT__SECRET_KEY: ${{ secrets.PRD_THOUGHTSPOT_SECRET_KEY }}
DIRECTORY: ${{ github.event_name == 'workflow_dispatch' && inputs.directory || 'dogfood' }}
TS_SOURCE_ENV_NAME: ${{ github.event_name == 'workflow_dispatch' && inputs.source_environment || 'ts-dev2' }}
TS_TARGET_ENV_NAME: ${{ github.event_name == 'workflow_dispatch' && inputs.target_environment || 'ts-prod' }}
TS_DESTINATION_ORG_ID: ${{ github.event_name == 'workflow_dispatch' && inputs.source_org || 'ArjunBiradar' }}
TS_METADATA_TYPES: ${{ github.event_name == 'workflow_dispatch' && inputs.metadata_types || 'ALL' }}
TS_OBJECT_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tags || 'testing' }}
TS_COMMIT_MESSAGE: "AUTOMATED >> TS-CI '${{ github.event.workflow }}' @ ${{ github.event.repository.updated_at }}"
TS_CONTENT_AUTHOR: ""
TS_SHARE_TO_GROUP: ""
TS_DEPLOY_TYPE: "DELTA"
TS_DEPLOY_POLICY: "ALL_OR_NONE"
TS_SHARE_MODE: "READ_ONLY"
# THE NAME OF YOUR BRANCH / THOUGHTSPOT ENVIRONMENT.
# TS_ENV_NAME: ts-prod
# THE ID OF THE ORG (THOUGHTSPOT ENVIRONMENT MATCHING ENV_NAME).
# TS_DESTINATION_ORG_ID: 1423467985
jobs:
run_deploy_api:
# if: github.event.pull_request.merged && github.event.pull_request.base.ref == '${{ github.env.TS_TRG_ENV_NAME }}'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checking ${{ env.TS_SOURCE_ENV_NAME }} branch
uses: actions/checkout@v4
with:
ref: ${{ env.TS_SOURCE_ENV_NAME }}
token: ${{ secrets.G_TOKEN }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install CS Tools
run: pip install "cs_tools[cli] @ https://github.com/thoughtspot/cs_tools/archive/${{ env.CS_TOOLS_VERSION }}.zip"
- name: Deploy TML to ThoughtSpot
run: |
cs_tools tools scriptability deploy \
--directory "${DIRECTORY}" \
--source-environment "${TS_SOURCE_ENV_NAME}" \
--target-environment "${TS_TARGET_ENV_NAME}" \
--deploy-type "${TS_DEPLOY_TYPE}" \
--deploy-policy "${TS_DEPLOY_POLICY}" \
--metadata-types "${TS_METADATA_TYPES}" \
--tags "${TS_OBJECT_TAG}" \
--org "${TS_DESTINATION_ORG_ID}" \
--log-errors \
--config "ENV:"
- name: Transfer Content Ownership
run: |
if [ -n "${{ env.TS_CONTENT_AUTHOR }}" ]; then
echo "Transferring ownership to ${{ env.TS_CONTENT_AUTHOR }}"
cs_tools tools user-management transfer \
--tags "${{ env.TS_OBJECT_TAG }}" \
--to "${{ env.TS_CONTENT_AUTHOR }}" \
--org "${{ env.TS_DESTINATION_ORG_ID }}" \
--config "ENV:"
else
echo "Skipping ASSIGN_CONTENT_AUTHOR as TS_CONTENT_AUTHOR is empty."
fi
- name: Share Content with Groups
run: |
if [ -n "${{ env.TS_SHARE_TO_GROUP }}" ]; then
echo "Sharing content with ${{ env.TS_SHARE_TO_GROUP }}"
cs_tools tools bulk-sharing from-tag \
--tag "${{ env.TS_OBJECT_TAG }}" \
--groups "${{ env.TS_SHARE_TO_GROUP }}" \
--share-mode "${{ env.TS_SHARE_MODE }}" \
--no-prompt \
--org "${{ env.TS_DESTINATION_ORG_ID }}" \
--config "ENV:"
else
echo "Skipping SHARING_CONTENT as TS_SHARE_TO_GROUP is empty."
fi
- name: Remove Temporary Tags
run: |
echo "Removing temporary tags"
cs_tools tools bulk-deleter from-tag \
--tag "${{ env.TS_OBJECT_TAG }}" \
--tag-only \
--no-prompt \
--org "${{ env.TS_DESTINATION_ORG_ID }}" \
--config "ENV:"
- name: Commit and Push TMLs
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add "${{ env.DIRECTORY }}/"
git commit -m "Update TML files [skip ci]" || echo "No changes to commit"
git push
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: tml-files
path: ${{ env.DIRECTORY }}/