Merge pull request #84 from pgoslatara/dependabot/pip/shandy-sqlfmt-j… #71
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: cd_pipeline | |
on: | |
push: | |
branches: | |
- stg | |
- prd | |
env: | |
DBT_DATASET: "cicd" | |
DBT_PROFILES_DIR: "." | |
GITHUB_RUN_NUMBER: ${{ github.run_number }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
cd_pipeline: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
- name: Extract branch name | |
shell: bash | |
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: Save stg GCP credentials to runner | |
run: | | |
echo "${{ secrets.DBT_CICD_SA_SECRET_KEY_STG_BASE64_ENCODED }}" | base64 --decode >> ./service_account.json && \ | |
export GOOGLE_APPLICATION_CREDENTIALS="$(pwd)/service_account.json" | |
if: ${{ steps.extract_branch.outputs.branch == 'stg' }} | |
- name: Save prd GCP credentials to runner | |
run: | | |
echo "${{ secrets.DBT_CICD_SA_SECRET_KEY_PRD_BASE64_ENCODED }}" | base64 --decode >> ./service_account.json && \ | |
export GOOGLE_APPLICATION_CREDENTIALS="$(pwd)/service_account.json" | |
if: ${{ steps.extract_branch.outputs.branch == 'prd' }} | |
- name: Authenticate with GCP | |
run: | | |
gcloud auth activate-service-account dbt-cicd@beyond-basics-${{ steps.extract_branch.outputs.branch }}.iam.gserviceaccount.com --key-file=./service_account.json && \ | |
gcloud config set project beyond-basics-${{ steps.extract_branch.outputs.branch }} | |
- name: Install python packages | |
run: pip install -r requirements.txt -r requirements_dev.txt | |
- run: dbt deps | |
- name: dbt debug | |
run: dbt debug --target ${{ steps.extract_branch.outputs.branch }} | |
- name: dbt seed | |
run: dbt seed --target ${{ steps.extract_branch.outputs.branch }} | |
- name: dbt compile | |
run: dbt compile --target ${{ steps.extract_branch.outputs.branch }} --threads 64 | |
- run: python ./scripts/upload_manifest_to_gcs.py --target-branch ${{ steps.extract_branch.outputs.branch }} | |
- run: python ./scripts/run_dbt_backfill.py --target-branch ${{ steps.extract_branch.outputs.branch }} |