Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Revert "Trigger build workflows for model on sqoop (#7)"
Browse files Browse the repository at this point in the history
This reverts commit bd59645.
  • Loading branch information
dfsnow committed Nov 30, 2023
1 parent bd59645 commit 785df03
Showing 1 changed file with 11 additions and 35 deletions.
46 changes: 11 additions & 35 deletions scripts/dispatch-dbt-workflow.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"}'

0 comments on commit 785df03

Please sign in to comment.