From 658c09479aa95b44d65a0ebd198eae387b72e0fd Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Sat, 19 Jun 2021 19:56:31 -0700 Subject: [PATCH] Make GitHub Actions build asynchronously --- .github/scripts/buildActions.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/scripts/buildActions.sh b/.github/scripts/buildActions.sh index 8b95647248b7..5b417b094f99 100755 --- a/.github/scripts/buildActions.sh +++ b/.github/scripts/buildActions.sh @@ -28,12 +28,26 @@ declare -r NOTE_DONT_EDIT='/** */ ' -for ACTION in "${GITHUB_ACTIONS[@]}"; do - # Build the action - ACTION_DIR=$(dirname "$ACTION") - ncc build "$ACTION" -o "$ACTION_DIR" - - # Prepend the warning note to the top of the compiled file - OUTPUT_FILE="$ACTION_DIR/index.js" - echo "$NOTE_DONT_EDIT$(cat "$OUTPUT_FILE")" > "$OUTPUT_FILE" +# This stores all the process IDs of the ncc commands so they can run in parallel +declare ASYNC_BUILDS + +for ((i=0; i < ${#GITHUB_ACTIONS[@]}; i++)); do + ACTION=${GITHUB_ACTIONS[$i]} + ACTION_DIR=$(dirname "$ACTION") + + # Build the action in the background + ncc build "$ACTION" -o "$ACTION_DIR" & + ASYNC_BUILDS[$i]=$! +done + +for ((i=0; i < ${#GITHUB_ACTIONS[@]}; i++)); do + ACTION=${GITHUB_ACTIONS[$i]} + ACTION_DIR=$(dirname "$ACTION") + + # Wait for the background build to finish + wait ${ASYNC_BUILDS[$i]} + + # Prepend the warning note to the top of the compiled file + OUTPUT_FILE="$ACTION_DIR/index.js" + echo "$NOTE_DONT_EDIT$(cat "$OUTPUT_FILE")" > "$OUTPUT_FILE" done