Last active
November 25, 2023 08:44
-
-
Save mat813/b7f78bcf70793212434480bfaf48675a to your computer and use it in GitHub Desktop.
Get current node version from .gitlab-ci.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use_mynode() { | |
local file=${1:-.gitlab-ci.yml} | |
local node_version | |
watch_file "$file" | |
# NODE_VERSION: 18.2.0-alpine | |
node_version=$(sed -n '/NODE_VERSION:/s/NODE_VERSION:[[:space:]]*\([^-]*\)\(-.*\)\?/\1/p' $file) | |
if [ -z "$node_version" ]; then | |
# NODE_IMAGE: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:18.2.0-alpine | |
node_version=$(sed -n '/NODE_IMAGE:/s/.*\bnode:\(.*\)-.*/\1/p' $file) | |
fi | |
if [[ -z ${node_version:-} ]]; then | |
log_error "File $file does not contain NODE_VERSION or NODE_IMAGE!" | |
return 1 | |
fi | |
log_status "Found NodeJS $node_version in $file" | |
use_node $node_version | |
layout_node | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment