Skip to content

Instantly share code, notes, and snippets.

@andreif
Created February 21, 2024 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreif/9aa1695864f25639b02872ece95cdd9e to your computer and use it in GitHub Desktop.
Save andreif/9aa1695864f25639b02872ece95cdd9e to your computer and use it in GitHub Desktop.
.npmrc
# $(call secret,region,account,secret_id)
define secret
$(shell aws secretsmanager get-secret-value \
--region $(1) --secret-id arn:aws:secretsmanager:$(1):$(2):secret:$(3) \
--output text --query SecretString)
endef
.npmrc: NPM_TOKEN ?= $(call secret,eu-west-1,1234567890,npm-readonly-token)
.npmrc:
@test -n "${NPM_TOKEN}" || (>&2 echo "Error: NPM_TOKEN is missing"; exit 1)
@echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
remove-old-npmrc:
@find . -maxdepth 1 -name ".npmrc" -type f -mtime +3 -exec rm {} \;
setup: remove-old-npmrc .npmrc ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment