Skip to content

Commit

Permalink
Merge pull request #1690 from SimenB/skip-yarn-update
Browse files Browse the repository at this point in the history
fix: only update yarn if there are other changes to the dockerfile
  • Loading branch information
nschonni authored Apr 8, 2022
2 parents d40c2c8 + 3f6cb08 commit 974a6c7
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,8 @@ function update_node_version() {
sed -Ei -e 's/^FROM (.*)/FROM '"$fromprefix"'\1/' "${dockerfile}-tmp"
sed -Ei -e 's/^(ENV NODE_VERSION ).*/\1'"${nodeVersion}"'/' "${dockerfile}-tmp"

if [ "${SKIP}" = true ]; then
# Get the currently used Yarn version
yarnVersion="$(grep "ENV YARN_VERSION" "${dockerfile}" | cut -d' ' -f3)"
fi
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${yarnVersion}"'/' "${dockerfile}-tmp"
currentYarnVersion="$(grep "ENV YARN_VERSION" "${dockerfile}" | cut -d' ' -f3)"
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${currentYarnVersion}"'/' "${dockerfile}-tmp"

# shellcheck disable=SC1004
new_line=' \\\
Expand Down Expand Up @@ -180,17 +177,22 @@ function update_node_version() {
sed -Ei -e "s/(debian:)name-slim/\\1${variant}/" "${dockerfile}-tmp"
fi

# Required for POSIX sed
if [ -f "${dockerfile}-tmp-e" ]; then
rm "${dockerfile}-tmp-e"
fi

if diff -q "${dockerfile}-tmp" "${dockerfile}" > /dev/null; then
echo "${dockerfile} is already up to date!"
else
if [ "${SKIP}" = true ]; then
# Get the currently used Yarn version
yarnVersion="$(grep "ENV YARN_VERSION" "${dockerfile}" | cut -d' ' -f3)"
fi
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${yarnVersion}"'/' "${dockerfile}-tmp"
echo "${dockerfile} updated!"
fi

# Required for POSIX sed
if [ -f "${dockerfile}-tmp-e" ]; then
rm "${dockerfile}-tmp-e"
fi

mv -f "${dockerfile}-tmp" "${dockerfile}"
)
}
Expand Down

0 comments on commit 974a6c7

Please sign in to comment.