@shelf/ci-utils

0.4.2 • Public • Published

@shelf/ci-utils

Install

$ npx -p=@shelf/ci-utils <cmd> [args...]

Usage

Get latest git tag version

Set the RELEASE_VERSION to .env file in your project.

Applicable for master branch only. For example, if you have a git tag v1.0.0 -> 1.0.0.

For other branches it will return latest.

npx -p=@shelf/ci-utils get-git-version

Get AWS SSM parameter

Set the SSM parameter name to .env file in your project. By default, It would append the ENVIRONMENT to the parameter name.

Yuo can override it by passing the whole parameter name in /<env>/<param-name> format (allowed envs: prod, staging).

npx -p=@shelf/ci-utils get-ssm-param <env-name> <param-name>

# Given: the /prod/s3_bucket parameter in SSM equals to 'my-prod-bucket' & ENVIRONMENT=prod
npx -p=@shelf/ci-utils get-ssm-param MY_PARAM s3_bucket # /prod/s3_bucket MY_PARAM=my-prod-bucket in .env
npx -p=@shelf/ci-utils get-ssm-param MY_PARAM /staging/s3_bucket # /staging/s3_bucket MY_PARAM=stage_bucket in .env

Set Nextjs base path

Sets the NEXT_BASE_PATH to .env file in your project based on the CIRCLE_BRANCH value. For main branches (master, develop, main) it will ignore the circle branch. The ci branch is normalized, see the nextjs-base-path.test.js file for details.

npx -p=@shelf/ci-utils set-nextjs-base-path <custom-base-path?>

# Given: CIRCLE_BRANCH=master
npx -p=@shelf/ci-utils set-nextjs-base-path # NEXT_BASE_PATH=
npx -p=@shelf/ci-utils get-ssm-param MY_PARAM read # NEXT_BASE_PATH=/read


# Given: CIRCLE_BRANCH=feature/ADMINAPP-123-feature-description
npx -p=@shelf/ci-utils set-nextjs-base-path # NEXT_BASE_PATH=/feature-ADMINAPP-123
npx -p=@shelf/ci-utils set-nextjs-base-path custom-path # NEXT_BASE_PATH=/custom-path-feature-ADMINAPP-123

# Given: CIRCLE_BRANCH=release/v1.0.0
npx -p=@shelf/ci-utils set-nextjs-base-path # NEXT_BASE_PATH=/release-v1.0.0
npx -p=@shelf/ci-utils set-nextjs-base-path custom-path # NEXT_BASE_PATH=/custom-path-release-v1.0.0
# Later it could be used in circleci/config.yml and next config to allow per-branch deployment
- run: npx -p=@shelf/ci-utils set-nextjs-base-path read
- run: yarn build
- run:
    name: deploy to s3
    command: |
      source .env
      aws s3 sync . "s3://$AWS_S3_BUCKET_NAME$NEXT_BASE_PATH" \
// next.config.js

const basePath = process.env.NEXT_BASE_PATH || '/read'; //default value for local development
export default {
  basePath: process.env.NEXT_BASE_PATH,
};

Publish

$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master --tags

License

MIT © Shelf

Readme

Keywords

none

Package Sidebar

Install

npm i @shelf/ci-utils

Weekly Downloads

1,541

Version

0.4.2

License

MIT

Unpacked Size

9.53 kB

Total Files

14

Last publish

Collaborators

  • el_scrambone
  • yuliiakovalchuk
  • anton-russo
  • gemshelf
  • mykola.khytra
  • hartzler
  • olesiamuller
  • nikita_shelf
  • vladgolubev
  • hmelenok
  • knupman
  • maaraanas
  • terret
  • chapelskyi.slavik
  • ahavrysh
  • pihorb
  • i5adovyi
  • irynah
  • diana.kryskuv
  • andy.raven
  • rafler
  • sskalp88
  • mykhailo.yatsko
  • demiansua
  • yuriil
  • vadymaslovskyi
  • ktv18
  • drews_abuse
  • rostyslav-horytskyi
  • whodeen
  • andriisermiahin
  • mpushkin
  • ss1l
  • oles.zadorozhnyy
  • maksym.hayovets
  • dima-bond
  • duch0416
  • kristina.zhak
  • oleksii.dymnich
  • domovoj
  • batovpavlo
  • mateuszgajdashelf
  • bodyaflesh
  • dmytro.harazdovskiy
  • kchlon
  • mmazurowski
  • vladmarchuk
  • petro.bodnarchuk
  • marianna-milovanova
  • kateryna-kochina
  • andrii-nastenko
  • maksym.tarnavskyi
  • bogdan.kolesnyk
  • andrew214
  • monopotan
  • maciej.orlowski