Skip to content

Commit

Permalink
Fix install javascript actions when one path has no build but cache i…
Browse files Browse the repository at this point in the history
…s hit
  • Loading branch information
jolelievre committed Sep 20, 2023
1 parent 5ea3ff3 commit 6644f1e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/actions/build-javascript/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,29 @@ runs:
buildLocks=''
IFS=$' \t\n'
commaSeparator=''
spaceSeparator=''
buildSeparator=''
installSeparator=''
lockSeparator=''
while read -r package_lock; do
if test -f "$package_lock"; then
js_folder=$(echo $package_lock | sed s_/package-lock\.json__)
package_json=$(echo $package_lock | sed s_package-lock\.json_package\.json_)
# Create/remove the lock at the beginning/end of the process so its presence can be checked
buildLocks+="$spaceSeparator$js_folder/buildLock"
buildLocks+="$lockSeparator$js_folder/buildLock"
# Only build when the action is in the package.json, we create a buildLock file to check when the build is really finished
# because sometimes the action switched to the next one while the build was not over
if grep -q '"build":' "$package_json"; then
buildCommandJson+="$commaSeparator\"(pushd $js_folder; touch buildLock; npm run build; rm buildLock; popd)\""
installAndBuildCommandJson+="$commaSeparator\"(pushd $js_folder; touch buildLock; npm ci; npm run build; rm buildLock; popd)\""
buildCommandJson+="$buildSeparator\"(pushd $js_folder; touch buildLock; npm run build; rm buildLock; popd)\""
installAndBuildCommandJson+="$installSeparator\"(pushd $js_folder; touch buildLock; npm ci; npm run build; rm buildLock; popd)\""
buildSeparator=', '
else
# Create/remove the lock at the beginning/end of the process so its presence can be checked
installAndBuildCommandJson+="$commaSeparator\"(pushd $js_folder; touch buildLock; npm ci; rm buildLock; popd)\""
installAndBuildCommandJson+="$installSeparator\"(pushd $js_folder; touch buildLock; npm ci; rm buildLock; popd)\""
fi
commaSeparator=', '
spaceSeparator=' '
installSeparator=', '
lockSeparator=' '
fi
done <<< "${{ inputs.package_locks }}"
Expand Down

0 comments on commit 6644f1e

Please sign in to comment.