changes to create demo project for dbt-model-erd (#35) #22
This file contains hidden or 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: "dbt prd pipeline" | |
| # Triggers | |
| on: | |
| # Triggers the workflow on push to main branch | |
| push: | |
| branches: | |
| - main | |
| # Triggers the workflow manually from GUI | |
| workflow_dispatch: | |
| jobs: | |
| # Build job | |
| build: | |
| runs-on: ubuntu-latest | |
| environment: prd | |
| env: | |
| ENV_CODE: ${{vars.ENV_CODE}} | |
| PROJ_CODE: ${{vars.PROJ_CODE}} | |
| SNOWSQL_ACCOUNT: ${{ secrets.SNOWSQL_ACCOUNT }} | |
| SNOWSQL_PWD: ${{ secrets.SNOWSQL_PWD }} | |
| steps: | |
| - name: "Step 01 - Checkout current branch" | |
| id: step-01 | |
| uses: actions/checkout@v3 | |
| - name: "Step 02 - Install dbt" | |
| id: step-02 | |
| run: pip3 install dbt-core dbt-snowflake | |
| - name: "Step 03 - Verify dbt" | |
| id: step-03 | |
| run: dbt --version | |
| - name: "Step 04 - Compile dbt" | |
| id: step-04 | |
| working-directory: ./dbt-docs/dbt | |
| run: | | |
| ls -ltra | |
| export DBT_PROFILES_DIR=$PWD | |
| dbt deps | |
| dbt debug -t $ENV_CODE | |
| dbt compile -t $ENV_CODE | |
| - name: "Step 05 - Generate dbt docs" | |
| id: step-05 | |
| working-directory: ./dbt-docs/dbt | |
| run: | | |
| export DBT_PROFILES_DIR=$PWD | |
| dbt deps | |
| dbt docs generate -t $ENV_CODE | |
| cd target | |
| mkdir ${{ github.workspace }}/docs | |
| cp *.json *.html graph.gpickle ${{ github.workspace }}/docs | |
| ls -ltra ${{ github.workspace }}/docs | |
| - name: "Step 06 - Upload pages to artifact" | |
| id: step-06 | |
| uses: actions/upload-pages-artifact@v2 | |
| with: | |
| path: ${{ github.workspace }}/docs | |
| - name: "Step 07 - Zip artifact" | |
| id: step-07 | |
| run: zip -jrq docs.zip ${{ github.workspace }}/docs | |
| - name: "Step 08 - Upload artifact for deployment job" | |
| id: step-08 | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: docs | |
| path: docs.zip | |
| # Deploy to Github pages | |
| deploy-to-github-pages: | |
| # Add a dependency to the build job | |
| needs: build | |
| # Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
| permissions: | |
| pages: write # to deploy to Pages | |
| id-token: write # to verify the deployment originates from an appropriate source | |
| # Deploy to the github-pages environment | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| # Specify runner + deployment step | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action | |
| # Deploy to Netlify | |
| deploy-to-netlify: | |
| # Add a dependency to the build job | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: prd | |
| steps: | |
| - name: "Step 01 - Download artifact" | |
| id: step-01 | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: docs | |
| path: ${{ github.workspace }} | |
| - name: "Step 02 - Unzip artifact" | |
| id: step-02 | |
| run: unzip ${{ github.workspace }}/docs.zip -d docs | |
| - name: "Step 03 - Deploy to Netlify" | |
| id: step-03 | |
| uses: nwtgck/actions-netlify@v2.0 | |
| with: | |
| production-branch: main | |
| publish-dir: ${{ github.workspace }}/docs | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| deploy-message: "Deploy from GitHub Actions" | |
| enable-pull-request-comment: true | |
| enable-commit-comment: false | |
| overwrites-pull-request-comment: true | |
| github-deployment-environment: prd | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
| timeout-minutes: 1 | |
| - run: "echo 'outputs.deploy-url: ${{ steps.step-03.outputs.deploy-url }}'" | |
| # Deploy to S3 | |
| deploy-to-s3: | |
| # Add a dependency to the build job | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: prd | |
| steps: | |
| - name: "Step 01 - Download artifact" | |
| id: step-01 | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: docs | |
| path: ${{ github.workspace }} | |
| - name: "Step 02 - Unzip artifact" | |
| id: step-02 | |
| run: unzip ${{ github.workspace }}/docs.zip -d docs | |
| - name: "Step 03 - Setup AWS CLI" | |
| id: step-03 | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ vars.AWS_DEFAULT_REGION }} | |
| - name: "Step 04 - Sync files to S3 bucket" | |
| run: | | |
| aws s3 sync ${{ github.workspace }}/docs ${{ vars.AWS_S3_BUCKET_DBT_DOCS }} --delete |