new workflow #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Our first dbt PR job | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
push: | |
branches: | |
- '!main' | |
jobs: | |
dbt_ci: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Set Up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
# Step 1: Create known_hosts and add the host key | |
- name: Create known_hosts file | |
run: | | |
mkdir -p ~/.ssh | |
touch ~/.ssh/known_hosts | |
- name: Add remote host key to known_hosts | |
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
# Step 2: Set up SSH and authenticate | |
- name: Add SSH private key | |
run: | | |
eval "$(ssh-agent -s)" | |
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" | |
# Step 3: Establish SSH tunnel | |
- name: Establish SSH tunnel | |
run: | | |
ssh -fN \ | |
-L 5432:${{ secrets.POSTGRES_HOST }}:5432 \ | |
${{ secrets.DB_USER }}@${{ secrets.SSH_HOST }} | |
- name: Install requirements | |
run: pip install -r requirements.txt | |
- name: Install dbt dependencies | |
run: dbt deps | |
- name: dbt build | |
run: dbt build --full-refresh --profiles-dir ./ | |
env: | |
POSTGRES_DBNAME: ${{ secrets.POSTGRES_DBNAME }} | |
POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
POSTGRES_HOST: 127.0.0.1 # Use localhost since we are tunneling via SSH | |
- name: Benchmarking models | |
run: "sqlfluff lint models --bench" | |
- name: Lint models | |
run: "sqlfluff lint models -f human" |