Commit 752f62e7 authored by Nathan Friend's avatar Nathan Friend

Merge branch 'add-node-ci-template' into 'master'

Change NodeJS example in GitLab CI templates to push to NPM registry

Closes #10050

See merge request gitlab-org/gitlab!25668
parents 5e470af3 e017940b
---
title: Add node ci template
merge_request: 25668
author:
type: other
image: node:latest
create_npmrc:
stage: build
script:
- |
if [ ! -f .npmrc ]; then
echo 'No .npmrc found! Creating one now. Please review the following link for more information: https://docs.gitlab.com/ee/user/packages/npm_registry/index.html#authenticating-with-a-ci-job-token'
echo "@${CI_PROJECT_NAMESPACE%%/*}:registry=\${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" >> .npmrc
echo '//gitlab.com/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}' >> .npmrc
echo '//gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}' >> .npmrc
fi
artifacts:
paths:
- .npmrc
publish_package:
stage: deploy
script:
- export NPM_PACKAGE_NAME=$(node -p "require('./package.json').name")
- export NPM_PACKAGE_VERSION=$(node -p "require('./package.json').version")
- |
{
npm publish &&
echo "Successfully published version $NPM_PACKAGE_VERSION of $NPM_PACKAGE_NAME to GitLab's NPM registry."
} || {
echo "No new version of $NPM_PACKAGE_NAME published. This is most likely because version $NPM_PACKAGE_VERSION already exists in GitLab's NPM registry."
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment