Skip to content

Commit

Permalink
Merge pull request #3702 from Expensify/Rory-AsyncGHActionsBuilds
Browse files Browse the repository at this point in the history
  • Loading branch information
deetergp authored Jun 22, 2021
2 parents cf7018e + 658c094 commit 3f3a97f
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions .github/scripts/buildActions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3f3a97f

Please sign in to comment.