Adding pizza_shape to dbt schema and Hashboard #17
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: Build DBT and Hashboard | |
| on: | |
| pull_request: | |
| types: [opened, synchronize] | |
| jobs: | |
| dbt-cloud-run: | |
| runs-on: ubuntu-latest | |
| env: | |
| HB_DBT_CLOUD_ACCOUNT_ID: 21999 | |
| DBT_JOB_ID: 740531 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Trigger DBT Cloud Job | |
| id: trigger-job | |
| run: | | |
| response=$(curl -X POST -s -w "\n%{http_code}" -H "Authorization: Token ${{ secrets.DBT_CLOUD_API_KEY }}" \ | |
| -H "Content-Type: application/json" \ | |
| "https://cloud.getdbt.com/api/v2/accounts/$HB_DBT_CLOUD_ACCOUNT_ID/jobs/$DBT_JOB_ID/run/" \ | |
| -d '{"cause": "Triggered by GH action", "git_branch": "${{ github.head_ref }}", "github_pull_request_id": ${{ github.event.pull_request.number }}}') | |
| http_code=$(echo "$response" | tail -n1) | |
| body=$(echo "$response" | sed '$d') | |
| if [ $http_code -ne 200 ]; then | |
| echo "Error: Received HTTP status code $http_code" | |
| echo "Response body: $body" | |
| exit 1 | |
| fi | |
| run_id=$(echo $body | jq -r '.data.id') | |
| if [ -z "$run_id" ] || [ "$run_id" = "null" ]; then | |
| echo "Error: Failed to extract job ID from response" | |
| echo "Response body: $body" | |
| exit 1 | |
| fi | |
| echo "RUN_ID=$run_id" >> $GITHUB_OUTPUT | |
| - name: "Install Python 3.9" | |
| id: install-python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Hashboard CLI | |
| run: | | |
| pip install dbt | |
| pip install hashboard-cli --pre | |
| - name: Create Hashboard build | |
| id: create-hb-build | |
| env: | |
| HB_DBT_CLOUD_AUTH_KEY: ${{ secrets.DBT_CLOUD_API_KEY }} | |
| HB_DBT_INCLUDE_DB_IN_SCHEMA: false | |
| HASHBOARD_PROJECT_ID: ${{ secrets.HASHBOARD_PROJECT_ID }} | |
| HASHBOARD_ACCESS_KEY_ID: ${{ secrets.HASHBOARD_ACCESS_KEY_ID }} | |
| HASHBOARD_SECRET_ACCESS_KEY_TOKEN: ${{ secrets.HASHBOARD_ACCESS_KEY_TOKEN }} | |
| HASHBOARD_CLI_BASE_URI: https://demo.hashboard.com # Remove this for non-demo actions | |
| run: | | |
| hb build --dbt-cloud-run-id=${{ steps.trigger-job.outputs.RUN_ID }} --staging-only | tee out.txt | |
| EXIT_CODE=${PIPESTATUS[0]} | |
| RESULT=$(cat out.txt | sed 's/`//g') | |
| EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
| echo "log<<$EOF" >> $GITHUB_OUTPUT | |
| echo "$RESULT" >> $GITHUB_OUTPUT | |
| echo "$EOF" >> $GITHUB_OUTPUT | |
| echo "exitCode=$EXIT_CODE" >> $GITHUB_OUTPUT | |
| - uses: actions/github-script@v6 | |
| name: "Comment on the pull request" | |
| with: | |
| script: | | |
| const backticks = '```'; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `${backticks}\n${{ steps.create-hb-build.outputs.log }}\n${backticks}` | |
| }) | |
| - id: set-appropriate-exit-code | |
| name: "Set exit code" | |
| run: exit "${{ steps.create-hb-build.outputs.exitCode }}" |