-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (65 loc) · 2.5 KB
/
start-preview.yml
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
name: start-preview
on:
push:
branches-ignore: [ "main", "master", "BETA_prod" ]
env:
DBT_VERSION: "1.8.1"
PROJECT_DIR: "./dbt_project.yml"
jobs:
preview:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
node-version: '20'
- uses: actions/setup-python@v1
with:
python-version: "3.9.x"
- name: Copy Google credentials file
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
if: "${{ env.GOOGLE_CREDENTIALS != '' }}"
id: create-json
uses: jsdaniell/[email protected]
with:
name: "googlecredentials.json"
json: ${{ env.GOOGLE_CREDENTIALS }}
- name: Move credentials to /tmp
run: mv googlecredentials.json /tmp || true
- name: Get lightdash version
uses: sergeysova/jq-action@v2
id: version
env:
LIGHTDASH_URL: ${{ secrets.LIGHTDASH_URL }}
with:
cmd: curl -s "${LIGHTDASH_URL}/api/v1/health" | jq -r '.results.version'
- name: Copy profiles.yml
env:
config: ${{ secrets.DBT_PROFILES }}
run: echo -e "$config" > profiles.yml
- name: Install dbt
run: |
pip install dbt-core==$DBT_VERSION dbt-postgres==$DBT_VERSION dbt-redshift==$DBT_VERSION dbt-snowflake==$DBT_VERSION dbt-bigquery==$DBT_VERSION
dbt deps --project-dir "$PROJECT_DIR"
- name: Install lightdash CLI
run: npm install -g "@lightdash/cli@${{ steps.version.outputs.value }}" || npm install -g @lightdash/cli@latest
- name: Lightdash CLI start preview
id: start-preview
env:
LIGHTDASH_API_KEY: ${{ secrets.LIGHTDASH_API_KEY }}
LIGHTDASH_PROJECT: ${{ secrets.LIGHTDASH_PROJECT }}
LIGHTDASH_URL: ${{ secrets.LIGHTDASH_URL }}
GOOGLE_APPLICATION_CREDENTIALS: '/tmp/googlecredentials.json'
run: lightdash start-preview --project-dir "$PROJECT_DIR" --profiles-dir . --name ${GITHUB_REF##*/}
- uses: jwalton/gh-find-current-pr@v1
id: finder
- name: Leave a comment after deployment
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ steps.finder.outputs.pr }}
message: |
:rocket: Deployed ${{ github.sha }} to ${{ steps.start-preview.outputs.url }}