Skip to content

Commit

Permalink
ENH Update reference to supported modules data (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored May 8, 2024
1 parent 412816b commit ed194eb
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ jobs:
else
BRANCH_MAJOR=${BASH_REMATCH[0]}
echo "Checking for supported modules in CMS $CMS_MAJOR against branch major $BRANCH_MAJOR"
curl -s -o __modules.json https://raw.githubusercontent.com/silverstripe/supported-modules/$CMS_MAJOR/modules.json
curl -s -o __modules.json https://raw.githubusercontent.com/silverstripe/supported-modules/main/repositories.json
# If we can't parse the JSON at all, $MODULES will be an empty string and that means we couldn't fetch the file.
MODULES=$(jq -e '.' __modules.json) || true
if [[ $MODULES == "" ]]; then
Expand All @@ -957,13 +957,26 @@ jobs:
# appended to the last line of the cat
echo ""
else
SUPPORTED_BRANCHES=$(jq -r --arg repo ${GITHUB_REPOSITORY} 'map(select(.github == $repo))[].branches[]' __modules.json)
SUPPORTED_BRANCH=$(echo $SUPPORTED_BRANCHES | grep -Po "$BRANCH_MAJOR" | head -n 1)
if [[ $SUPPORTED_BRANCH == "" ]]; then
echo "Not a supported module or branch"
SUPPORTED_BRANCHES=$(jq -r --arg repo ${GITHUB_REPOSITORY} --arg cmsmajor ${CMS_MAJOR} '.[] | map(select(.github == $repo))[].majorVersionMapping | .[$cmsmajor]' __modules.json)
if [[ $SUPPORTED_BRANCHES == "null" ]]; then
# Check if this repository has a mapping against arbitrary CMS majors.
# This is represented by a major version mapping of "*" to either an empty array, or an array with the current branch in it.
SUPPORTED_BRANCHES=$(jq -r --arg repo ${GITHUB_REPOSITORY} '.[] | map(select(.github == $repo))[].majorVersionMapping | select(has("*"))[]' __modules.json)
if [[ $SUPPORTED_BRANCHES == "[]" || $(echo '["5"]' | jq -r --arg branch ${BRANCH_MAJOR} 'index($branch)') != "null" ]]; then
echo "Repository is supported"
CAN_TAG=1
else
echo "Not a supported module or branch"
fi
else
echo "Repository is supported"
CAN_TAG=1
# We have an array of branches - check if the branch major is included
SUPPORTED_BRANCH=$(echo $SUPPORTED_BRANCHES | grep -Po "$BRANCH_MAJOR" | head -n 1)
if [[ $SUPPORTED_BRANCH == "" ]]; then
echo "Not a supported module or branch"
else
echo "Repository is supported"
CAN_TAG=1
fi
fi
fi
fi
Expand Down

0 comments on commit ed194eb

Please sign in to comment.