Skip to content

Commit d3b9993

Browse files
Merge pull request #148 from bryanthowell-ts/actions_work_1
First version of scheduled version control
2 parents 1fef17e + c0e143c commit d3b9993

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Version Control vc_dev branch
5+
6+
on:
7+
schedule:
8+
- cron: '*/15 * * * *' # Example: Runs every 15 minutes
9+
# workflow_dispatch:
10+
# inputs:
11+
# OBJECT_TYPE:
12+
# type: choice
13+
# description: Type of Objects to Download
14+
# options:
15+
# - ALL
16+
# - LIVEBOARD
17+
# - ANSWER
18+
# - DATA
19+
# - CONNECTION
20+
# required: true
21+
# RECORD_SIZE_LIMIT:
22+
# type: number
23+
# description: Limit Number Objects Downloaded (-1 is All)
24+
# default: "-1"
25+
# required: true
26+
# FILTER_AUTHOR_NAME:
27+
# type: string
28+
# description: 'Filter to Author (Owner) Name'
29+
# required: true
30+
# default: "{None}"
31+
# FILTER_TAG_NAME:
32+
# type: string
33+
# description: 'Filter on Tag name'
34+
# required: true
35+
# default: "{None}"
36+
# TS_ORG_NAME_OVERRIDE:
37+
# type: string
38+
# description: 'ThoughtSpot org name (not org_id)'
39+
# required: true
40+
# default: '{None}'
41+
42+
43+
permissions:
44+
contents: write
45+
46+
jobs:
47+
download_tml_and_commit:
48+
49+
runs-on: ubuntu-latest
50+
# Maps a Git branch (the == '{branchName}' to a GitHub environment ( the && '{envName}')
51+
# These are the suggested best practice names in a simple multi-tenant deployment
52+
environment: 'dev'
53+
54+
steps:
55+
- uses: actions/checkout@v4
56+
with:
57+
ref: 'vc_dev'
58+
- name: Set up Python 3.10
59+
uses: actions/setup-python@v3
60+
with:
61+
python-version: "3.10"
62+
- name: Install dependencies
63+
run: |
64+
python -m pip install --upgrade pip
65+
pip install thoughtspot_rest_api
66+
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
67+
- name: Get Org_ID from Org_Name ${{ vars.TS_ORG_NAME }}
68+
env:
69+
TS_SERVER: ${{ secrets.TS_SERVER }}
70+
TS_SECRET_KEY: ${{ secrets.TS_SECRET_KEY }}
71+
TS_USERNAME: ${{ secrets.TS_INSTANCE_ADMIN_USERNAME }}
72+
TS_ORG_NAME: ${{ vars.TS_ORG_NAME }}
73+
run: |
74+
python .github/workflows/retrieve_org_id_from_org_name.py >> $GITHUB_ENV
75+
- name: Export and Download TML from ${{ vars.TS_ORG_NAME }}
76+
env:
77+
TS_SERVER: ${{ secrets.TS_SERVER }}
78+
TS_SECRET_KEY: ${{ secrets.TS_SECRET_KEY }}
79+
TS_USERNAME: ${{ secrets.TS_DOWNLOAD_USERNAME }}
80+
AUTHOR_FILTER: "{None}"
81+
TAG_FILTER: "{None}"
82+
OBJECT_TYPE: "ALL"
83+
RECORD_SIZE_LIMIT: "-1"
84+
run: |
85+
git config --local user.email "${{ github.actor_id }}+${{ github.triggering_actor }}@users.noreply.github.com"
86+
git config --local user.name "${{ github.triggering_actor }}"
87+
python .github/workflows/download_tml_to_disk.py
88+
git add *
89+
git diff-index --quiet HEAD || git commit -a -m "Run ID ${{ github.run_id }}/${{github.run_attempt}} export from Org ${{ vars.TS_ORG_NAME }}"
90+
git push

0 commit comments

Comments
 (0)