I am using NX and CircleCI to deploy my project to firebase.
I create a command nx:affected:deploy
which should deploy only affected build based on previous commit to develop
branch.
my config.yml
from CircleCI
looks like this
version: 2
jobs:
test_affected:
docker:
- image: circleci/node:12-browsers
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: npm install
- save_cache:
key: v1-npm-deps-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- run: npm run affected:dev:stylelint
- run: npm run affected:dev:lint
- run: npm run affected:dev:test
- persist_to_workspace:
root: .
paths:
- .
deploy_affected:
docker:
- image: circleci/node:12
steps:
- checkout
- run: npm i
- run: npm run affected:dev:deploy
workflows:
version: 2
build_and_deploy:
jobs:
- test_affected
- deploy_affected:
requires:
- test_affected
filters:
branches:
only: develop
now, the problem is, when deploy_affected
run, the commit is already pushed to develop
and nothing trigger (since develop and affected look for the same commit), so I need to set the target to the previous commit SHA on develop.
I know in github actions we can do :
env:
BEFORE_SHA: ${{ github.event.before }}
but I can’t find a simple way on CircleCli config.
I mean, there is this => circleci-monorepo/circle_trigger.sh at master · labs42io/circleci-monorepo · GitHub
But it s a lot of code for a simple action
EDIT :
I tried to use :
environment:
LASTEST_SHA1: echo -e $(git rev-list -n 1 origin/develop^1)
LASTEST_SHA2: << pipeline.git.base_revision >>
steps:
- run:
command: |
echo $LASTEST_SHA1
echo $LASTEST_SHA2
but the result are the same value I set…
echo -e $(git rev-list -n 1 origin/develop^1)
<< pipeline.git.base_revision >>