Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions bash/bin/dcp_trigger_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
# Trigger GitHub Actions build workflow for current branch
# Usage: dcp_trigger_build [dataset] [recipe] [build_note] [--no-tail]

set -e

# Parse options
TAIL_LOGS=true
ARGS=()
for arg in "$@"; do
if [ "$arg" = "--no-tail" ]; then
TAIL_LOGS=false
else
ARGS+=("$arg")
fi
done

DATASET="${ARGS[0]:-${DATASET}}"
RECIPE="${ARGS[1]:-recipe}"
BUILD_NOTE="${ARGS[2]}"
BRANCH=$(git branch --show-current)

if [ -z "$DATASET" ]; then
echo "Error: DATASET must be set as env var or passed as first argument"
echo "Usage: dcp_trigger_build <dataset> [recipe] [build_note] [--no-tail]"
echo " or: DATASET=pluto dcp_trigger_build [recipe] [build_note] [--no-tail]"
exit 1
fi

echo "Triggering build workflow for:"
echo " Dataset: $DATASET"
echo " Recipe: $RECIPE"
echo " Branch: $BRANCH"
if [ -n "$BUILD_NOTE" ]; then
echo " Note: $BUILD_NOTE"
fi
echo ""

WORKFLOW_ARGS=(
--ref "$BRANCH"
-f dataset_name="$DATASET"
-f recipe_file="$RECIPE"
-f test_severity=warn
)

if [ -n "$BUILD_NOTE" ]; then
WORKFLOW_ARGS+=(-f build_note="$BUILD_NOTE")
fi

gh workflow run build.yml "${WORKFLOW_ARGS[@]}"

echo ""
echo "✓ Workflow dispatched!"
echo ""

# Wait a moment for the run to appear in the API
sleep 2

# Get the most recent run for this workflow and branch
RUN_INFO=$(gh run list --workflow=build.yml --branch="$BRANCH" --limit 1 --json databaseId,url --jq '.[0]')
RUN_URL=$(echo "$RUN_INFO" | jq -r '.url')
RUN_ID=$(echo "$RUN_INFO" | jq -r '.databaseId')

if [ -n "$RUN_URL" ]; then
# Create clickable hyperlink using ANSI escape codes
echo -e "View run: \033]8;;${RUN_URL}\033\\${RUN_URL}\033]8;;\033\\"
if [ "$TAIL_LOGS" = true ]; then
echo ""
echo "Tailing logs..."
gh run watch "$RUN_ID"
fi
else
echo "View runs: gh run list --workflow=build.yml --branch=$BRANCH"
fi
1 change: 1 addition & 0 deletions products/cbbr/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-cbbr
export DATASET=cbbr

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/cdbg/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-cdbg
export DATASET=cdbg

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/ceqr/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-ceqr
export DATASET=ceqr

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/checkbook/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-checkbook
export DATASET=checkbook

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/colp/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-colp
export DATASET=colp

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/cpdb/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-cpdb
export DATASET=cpdb

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/cscl/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-cscl
export DATASET=cscl

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/developments/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-devdb
export DATASET=developments

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
2 changes: 2 additions & 0 deletions products/edde/.envrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source_up

export DATASET=edde

# Load local .env if it exists
if [ -f .env ]; then
dotenv .env
Expand Down
1 change: 1 addition & 0 deletions products/facilities/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-facilities
export DATASET=facilities

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/factfinder/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-factfinder
export DATASET=factfinder

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/green_fast_track/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-green_fast_track
export DATASET=green_fast_track

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
2 changes: 2 additions & 0 deletions products/knownprojects/.envrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source_up

export DATASET=knownprojects

# Load local .env if it exists
if [ -f .env ]; then
dotenv .env
Expand Down
1 change: 1 addition & 0 deletions products/pluto/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-pluto
export DATASET=pluto

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/template/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-template
export DATASET=template

# Load local .env if it exists
if [ -f .env ]; then
Expand Down
1 change: 1 addition & 0 deletions products/zoningtaxlots/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source_up

export BUILD_ENGINE_DB=db-ztl
export DATASET=ztl

# Load local .env if it exists
if [ -f .env ]; then
Expand Down