Skip to content

Commit

Permalink
added cache
Browse files Browse the repository at this point in the history
  • Loading branch information
luutuankiet committed Aug 25, 2024
1 parent ccac0cf commit d09e31f
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions .github/workflows/start-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
env:
DBT_VERSION: "1.8.1"
PROJECT_DIR: "./dbt_project"
DW_DBNAME: "gtd_dash"

jobs:
preview:
Expand All @@ -16,13 +17,44 @@ jobs:
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]

- name: Cache Python packages
uses: actions/cache@v3
with:
node-version: '20'
path: |
~/.cache/pip
~/.local
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/setup-python@v1
with:
python-version: "3.9.x"

- name: Install Python dependencies
run: |
pip install -r requirements.txt
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: Cache npm packages
uses: actions/cache@v3
with:
path: |
~/.npm
~/.cache/npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/[email protected]
with:
node-version: '20'

- name: Install npm dependencies
run: npm install -g "@lightdash/cli@${{ steps.version.outputs.value }}" || npm install -g @lightdash/cli@latest

- name: Copy Google credentials file
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
Expand All @@ -49,21 +81,13 @@ jobs:
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
Expand All @@ -74,4 +98,4 @@ jobs:
with:
number: ${{ steps.finder.outputs.pr }}
message: |
:rocket: Deployed ${{ github.sha }} to ${{ steps.start-preview.outputs.url }}
:rocket: Deployed ${{ github.sha }} to ${{ steps.start-preview.outputs.url }}

0 comments on commit d09e31f

Please sign in to comment.