Skip to content

Commit 7323e87

Browse files
authored
Refactor CI workflow for Lightdash deployment
Updated CI workflow for Lightdash deployment with new steps for credential handling and dbt installation.
1 parent b9cf87c commit 7323e87

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
name: deploy-lightdash
3+
4+
on:
5+
push:
6+
branches: [ "main", "master" ]
7+
8+
env:
9+
DBT_VERSION: "1.9.0"
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/[email protected]
18+
- uses: actions/setup-python@v1
19+
with:
20+
python-version: "3.9.x"
21+
22+
- name: Copy Google credentials file
23+
env:
24+
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
25+
if: "${{ env.GOOGLE_CREDENTIALS != '' }}"
26+
id: create-json
27+
uses: jsdaniell/[email protected]
28+
with:
29+
name: "googlecredentials.json"
30+
json: ${{ env.GOOGLE_CREDENTIALS }}
31+
32+
- name: Move credentials to /tmp
33+
run: mv googlecredentials.json /tmp || true
34+
35+
- name: Locate dbt_project.yml
36+
run: echo "PROJECT_DIR=$(find . -name "dbt_project.yml" | sed 's/dbt_project.yml//g')" >> $GITHUB_ENV
37+
38+
- name: Get lightdash version
39+
uses: sergeysova/jq-action@v2
40+
id: version
41+
env:
42+
LIGHTDASH_URL: ${{ secrets.LIGHTDASH_URL }}
43+
with:
44+
cmd: curl -s "${LIGHTDASH_URL}/api/v1/health" | jq -r '.results.version'
45+
46+
- name: Copy profiles.yml
47+
env:
48+
config: ${{ secrets.DBT_PROFILES }}
49+
run: echo -e "$config" > profiles.yml
50+
51+
- name: Install dbt
52+
run: |
53+
pip install dbt-core==$DBT_VERSION dbt-bigquery==$DBT_VERSION
54+
dbt deps --project-dir "$PROJECT_DIR"
55+
56+
- name: Install lightdash CLI
57+
run: npm install -g "@lightdash/cli@${{ steps.version.outputs.value }}" || npm install -g @lightdash/cli@latest
58+
59+
- name: Lightdash CLI deploy
60+
env:
61+
LIGHTDASH_API_KEY: ${{ secrets.LIGHTDASH_API_KEY }}
62+
LIGHTDASH_PROJECT: ${{ secrets.LIGHTDASH_PROJECT }}
63+
LIGHTDASH_URL: ${{ secrets.LIGHTDASH_URL }}
64+
GOOGLE_APPLICATION_CREDENTIALS: '/tmp/googlecredentials.json'
65+
66+
run: lightdash deploy --project-dir "$PROJECT_DIR" --profiles-dir . --profile prod || lightdash deploy --project-dir "$PROJECT_DIR" --profiles-dir .

0 commit comments

Comments
 (0)