-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·45 lines (35 loc) · 1.67 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·45 lines (35 loc) · 1.67 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
45
#! /bin/sh
echo "GitHub repository: ${GITHUB_REPOSITORY}"
echo "GitHub ref: ${GITHUB_REF}"
echo "GitHub actor: ${GITHUB_ACTOR}"
echo "GitHub SHA: ${GITHUB_SHA}"
input_version=$(basename "${GITHUB_REF}")
input_component=$(basename "${GITHUB_REPOSITORY}")
# if workflow was triggered by branch other than develop,
# use METplus component versions script to determine METplus main_vX.Y branch
metplus_branch=develop
if [ "${input_version}" != "develop" ]; then
# get METplus develop branch to get component versions script
# and to query remote to check for existence of branch
git clone --single-branch --branch develop https://github.com/dtcenter/METplus
cmd="./METplus/metplus/component_versions.py -i ${input_component} -v ${input_version} -o METplus -f main_v{X}.{Y}"
echo "$cmd"
metplus_branch=$($cmd)
# if no branch can be determined, exit and error
if [ -z "${metplus_branch}" ]; then
echo "ERROR: Could not get METplus branch"
exit 1
fi
# if branch doesn't exist in remote, do not trigger METplus workflow
branch_exists=$(git -C ./METplus ls-remote origin "${metplus_branch}")
if [ -z "${branch_exists}" ]; then
echo "WARNING: METplus branch ${metplus_branch} does not exist yet"
exit 0
fi
fi
# set env var to authenticate GitHub API
export GH_TOKEN="${INPUT_TOKEN}"
# trigger workflow using gh cli
json_inputs="{\"actor\": \"${GITHUB_ACTOR}\",\"ref\": \"${GITHUB_REF}\",\"repository\": \"${GITHUB_REPOSITORY}\",\"sha\": \"${GITHUB_SHA}\"}"
echo "Triggering METplus testing workflow on ${metplus_branch} branch using inputs: ${json_inputs}"
echo "${json_inputs}" | gh workflow run testing.yml --repo dtcenter/METplus --ref "${metplus_branch}" --json