Skip to content

Commit e4103a9

Browse files
Merge pull request #44 from creative-commoners/pulls/1.1/misc-array
FIX Make JS update action compatible with node tools
2 parents f8d3ab8 + c142fcd commit e4103a9

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

action.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ runs:
121121
echo "framework_supported_major=$FRAMEWORK_SUPPORTED_MAJOR" >> "$GITHUB_OUTPUT"
122122
# Create a module map of { module_major: cms_version }
123123
# e.g. for silverstripe/admin it will be { "1": "4", "2": "5", "3": "6" }
124-
MODULE_MAP=$(jq -r --arg github_repository "$GITHUB_REPOSITORY" '.supportedModules[] | select(.github == $github_repository) | .majorVersionMapping | to_entries | map({key: .value[0], value: .key}) | from_entries' __repositories.json)
124+
MODULE_MAP=$(jq -r --arg github_repository "$GITHUB_REPOSITORY" '(.supportedModules + .misc)[] | select(.github == $github_repository) | .majorVersionMapping | to_entries | map({key: .value[0], value: .key}) | from_entries' __repositories.json)
125125
echo "MODULE_MAP is $MODULE_MAP"
126126
rm __repositories.json
127127
# Work out the CMS version that $DEFAULT_BRANCH maps to
@@ -376,7 +376,11 @@ runs:
376376
if: inputs.branch_type != 'schedule' && steps.derive-module-branch.outputs.proceed == '1'
377377
shell: bash
378378
run: |
379-
NODE_ENV=production node_modules/.bin/webpack --mode production --bail --progress
379+
if [[ -f node_modules/.bin/webpack-cli ]]; then
380+
NODE_ENV=production node_modules/.bin/webpack --mode production --bail --progress
381+
else
382+
echo "webpack-cli is not installed, skipping webpack build"
383+
fi
380384
381385
- name: Remove any old pull-requests
382386
if: inputs.branch_type != 'schedule' && steps.derive-module-branch.outputs.proceed == '1'
@@ -490,8 +494,20 @@ runs:
490494
rm __pull_requests.json
491495
fi
492496
493-
- name: Derive PR branch name
497+
- name: Check for changes
498+
id: check-changes
494499
if: inputs.branch_type != 'schedule' && steps.derive-module-branch.outputs.proceed == '1'
500+
shell: bash
501+
run: |
502+
if [[ -z "$(git status --porcelain)" ]]; then
503+
echo "No changes detected, skipping pull-request creation"
504+
echo "has_changes=0" >> "$GITHUB_OUTPUT"
505+
else
506+
echo "has_changes=1" >> "$GITHUB_OUTPUT"
507+
fi
508+
509+
- name: Derive PR branch name
510+
if: inputs.branch_type != 'schedule' && steps.derive-module-branch.outputs.proceed == '1' && steps.check-changes.outputs.has_changes == '1'
495511
id: derive-pr-branch-name
496512
shell: bash
497513
env:
@@ -502,7 +518,7 @@ runs:
502518
echo "pr_branch=$PR_BRANCH" >> "$GITHUB_OUTPUT"
503519
504520
- name: Git
505-
if: inputs.branch_type != 'schedule' && steps.derive-module-branch.outputs.proceed == '1'
521+
if: inputs.branch_type != 'schedule' && steps.derive-module-branch.outputs.proceed == '1' && steps.check-changes.outputs.has_changes == '1'
506522
uses: silverstripe/gha-pull-request@v1
507523
with:
508524
branch: ${{ steps.derive-pr-branch-name.outputs.pr_branch }}

0 commit comments

Comments
 (0)