-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
buildActions.sh
executable file
·58 lines (49 loc) · 2.27 KB
/
buildActions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#
# Used to precompile all Github Action node.js scripts using ncc.
# This bundles them with their dependencies into a single executable node.js script.
# In order for this script to be safely run from anywhere, we cannot use the raw relative path '../actions'.
declare ACTIONS_DIR
ACTIONS_DIR="$(dirname "$(dirname "$0")")/actions/javascript"
# List of paths to all JS files that implement our GH Actions
declare -r GITHUB_ACTIONS=(
"$ACTIONS_DIR/awaitStagingDeploys/awaitStagingDeploys.js"
"$ACTIONS_DIR/bumpVersion/bumpVersion.js"
"$ACTIONS_DIR/checkDeployBlockers/checkDeployBlockers.js"
"$ACTIONS_DIR/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js"
"$ACTIONS_DIR/getDeployPullRequestList/getDeployPullRequestList.js"
"$ACTIONS_DIR/getPreviousVersion/getPreviousVersion.js"
"$ACTIONS_DIR/getPullRequestDetails/getPullRequestDetails.js"
"$ACTIONS_DIR/getReleaseBody/getReleaseBody.js"
"$ACTIONS_DIR/isStagingDeployLocked/isStagingDeployLocked.js"
"$ACTIONS_DIR/markPullRequestsAsDeployed/markPullRequestsAsDeployed.js"
"$ACTIONS_DIR/postTestBuildComment/postTestBuildComment.js"
"$ACTIONS_DIR/reopenIssueWithComment/reopenIssueWithComment.js"
"$ACTIONS_DIR/verifySignedCommits/verifySignedCommits.js"
"$ACTIONS_DIR/authorChecklist/authorChecklist.ts"
"$ACTIONS_DIR/reviewerChecklist/reviewerChecklist.js"
"$ACTIONS_DIR/validateReassureOutput/validateReassureOutput.js"
)
# This will be inserted at the top of all compiled files as a warning to devs.
declare -r NOTE_DONT_EDIT='/**
* NOTE: This is a compiled file. DO NOT directly edit this 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