-
Notifications
You must be signed in to change notification settings - Fork 330
Expand file tree
/
Copy pathenv.sh
More file actions
44 lines (43 loc) · 1.33 KB
/
env.sh
File metadata and controls
44 lines (43 loc) · 1.33 KB
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
#!/bin/bash
function testworkflow() {
local EVENT_TYPE=$1
local SCENARIO=$2
# Get workflow name
local TEST_PATH
TEST_PATH=$(dirname "$(readlink -f "${BASH_SOURCE[1]}")")
local WORKFLOW_NAME
WORKFLOW_NAME=$(basename "$TEST_PATH")
local WORKFLOW_FILE=.github/workflows/${WORKFLOW_NAME}.yaml
local PAYLOAD_FILE
PAYLOAD_FILE=${TEST_PATH}/payload-${EVENT_TYPE//_/-}
if [ "$SCENARIO" != "" ]; then
PAYLOAD_FILE=${PAYLOAD_FILE}-${SCENARIO}
fi
PAYLOAD_FILE=${PAYLOAD_FILE}.json
# Move to project root directory
local FILE_PATH
FILE_PATH=$(dirname "$0")
pushd "$FILE_PATH/../../../../" || exit 1
# Check if workflow file and payload file exist
if [ ! -f "$WORKFLOW_FILE" ]; then
echo "Workflow file not found: $WORKFLOW_FILE"
exit 1
fi
if [ ! -f "$PAYLOAD_FILE" ]; then
echo "Payload file not found: $PAYLOAD_FILE"
exit 1
fi
# Run workflow using act
act "${EVENT_TYPE}" \
--workflows "${WORKFLOW_FILE}" \
--eventpath "${PAYLOAD_FILE}" \
--container-architecture linux/amd64 \
--secret GITHUB_TOKEN="$(gh auth token)" \
--verbose
# Capture the exit code
local EXIT_CODE=$?
# Move back to initial directory
popd || exit 1
# Return the test exit code
return $EXIT_CODE
}