name: dbt_run_template_docs_update on: workflow_call: inputs: resource_id: description: 'DDS resource ID to refresh (defaults to repository name if not provided)' required: false type: string jobs: run_dbt_jobs_refresh: runs-on: ubuntu-latest environment: name: workflow_secrets steps: - uses: actions/checkout@v3 - name: Extract project & profile names from dbt_project.yml id: project-name run: | PROFILE_NAME=$(grep "^profile:" dbt_project.yml | sed 's/^profile:[[:space:]]*"//' | sed 's/".*$//') PROJECT_NAME=$(grep "^name:" dbt_project.yml | sed 's/^name:[[:space:]]*"//' | sed 's/".*$//') echo "PROFILE_NAME=$PROFILE_NAME" >> $GITHUB_ENV echo "PROJECT_NAME=$PROJECT_NAME" >> $GITHUB_ENV echo "PROFILE_NAME: $PROFILE_NAME" echo "PROJECT_NAME: $PROJECT_NAME" - name: Set production environment variables run: | echo "TARGET=prod" >> $GITHUB_ENV echo "ACCOUNT=vna27887.us-east-1" >> $GITHUB_ENV echo "REGION=us-east-1" >> $GITHUB_ENV echo "SCHEMA=ADMIN" >> $GITHUB_ENV echo "DATABASE=$PROFILE_NAME" >> $GITHUB_ENV echo "ROLE=DBT_CLOUD_$PROFILE_NAME" >> $GITHUB_ENV echo "USER=DBT_CLOUD_$PROFILE_NAME" >> $GITHUB_ENV echo "WAREHOUSE=DBT_CLOUD" >> $GITHUB_ENV echo "PASSWORD=${{ secrets.PASSWORD }}" >> $GITHUB_ENV - uses: actions/setup-python@v4 with: python-version: "3.10" cache: "pip" - name: Configure git for internal repos run: git config --global url."https://x-access-token:${{ secrets.GH_INTERNAL_TOKEN }}@github.com/".insteadOf "https://github.com/" - name: Install dependencies run: | pip install -r requirements.txt dbt deps - name: deploy seed files run: | dbt seed -t prod - name: checkout docs branch run: | git checkout -B docs origin/main - name: generate dbt docs run: dbt docs generate -t prod --select "$PROJECT_NAME.*" "fsc_evm,tag:core" "fsc_evm,tag:prices" "fsc_evm,tag:labels" "fsc_evm,tag:balances" "fsc_evm,tag:decoded_logs" "fsc_evm,tag:abis" "fsc_evm,tag:defi" "fsc_evm,tag:stats" - name: move files to docs directory run: | mkdir -p ./docs cp target/{catalog.json,manifest.json,index.html} docs/ - name: clean up target directory run: dbt clean - name: check for changes run: git status - name: stage changed files run: git add . - name: commit changed files run: | git config user.email "abc@xyz" git config user.name "github-actions" git commit -am "Auto-update docs" - name: push changes to docs run: | git push -f --set-upstream origin docs refresh-dds-cache: needs: [run_dbt_jobs_refresh] if: success() uses: FlipsideCrypto/analytics-workflow-templates/.github/workflows/refresh_dds.yml@main with: resource_id: ${{ inputs.resource_id }} api_url: ${{ github.ref == 'refs/heads/main' && 'https://dds-api.fsc-data-platform.io' || 'https://dds-api.fsc-data-platform-stg.io' }} force_refresh: true secrets: DDS_API_KEY: ${{ github.ref == 'refs/heads/main' && secrets.DDS_PROD_API_KEY || secrets.DDS_STG_API_KEY }} notify-failure: needs: [run_dbt_jobs_refresh, refresh-dds-cache] if: failure() uses: ./.github/workflows/slack_notify.yml secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}