diff --git a/scripts/dispatch-dbt-workflow.sh b/scripts/dispatch-dbt-workflow.sh index e328a54..1eb3c0a 100755 --- a/scripts/dispatch-dbt-workflow.sh +++ b/scripts/dispatch-dbt-workflow.sh @@ -1,21 +1,7 @@ #!/bin/bash -# These arrays are essentially "rows" of data, where each index (starting -# with 0) represents a set of values this script will iterate through i.e. -# For index 1, run build_and_test_dbt.yaml with model.vw_card_res_input and -# model.vw_pin_condo_input as inputs to the workflow -GH_API_REPOS=( - "https://api.github.com/repos/ccao-data/data-architecture" - "https://api.github.com/repos/ccao-data/data-architecture" -) -GH_API_WORKFLOWS=( - "test_dbt_models.yaml" - "build_and_test_dbt.yaml" -) -GH_API_WORKFLOW_INPUTS=( - "" - "model.vw_card_res_input model.vw_pin_condo_input" -) +GH_API_REPO="https://api.github.com/repos/ccao-data/data-architecture" +GH_DBT_WORKFLOW="test_dbt_models.yaml" # First auth as a GitHub app using JSON Web Token (JWT). # Uses a local PEM file and python lib to construct the JWT @@ -42,22 +28,12 @@ GH_TOKEN=$(curl -s -L \ "$GH_TOKENS_URL" \ | jq -r '.token') -# Use the token to call the API and dispatch the workflows -echo "Dispatching workflows" -for i in ${!GH_API_REPOS[*]}; do - GH_API_PARAMS=$( - if [ -z "${GH_API_WORKFLOW_INPUTS[$i]}" ]; then - echo '{"ref": "master"}' - else - echo "{\"ref\": \"master\", \"inputs\": {\"models\": \"${GH_API_WORKFLOW_INPUTS[$i]}\"}}" - fi - ) - - curl -s -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${GH_TOKEN}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "${GH_API_REPOS[$i]}"/actions/workflows/"${GH_API_WORKFLOWS[$i]}"/dispatches \ - -d "${GH_API_PARAMS}" -done +# Use the token to call the API and dispatch the workflow +echo "Dispatching workflow" +curl -s -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GH_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "$GH_API_REPO"/actions/workflows/"$GH_DBT_WORKFLOW"/dispatches \ + -d '{"ref": "master"}'