Skip to content

Commit

Permalink
circle
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfdsilva committed Jan 29, 2019
1 parent 8ea51d7 commit c436417
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
version: 2
jobs:
test:
docker:
- image: node:8

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: yarn install

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

- run: yarn test

check_version:
docker:
- image: node:8

working_directory: ~/repo

environment:
- PRODUCTION_BRANCH: master

steps:
- checkout

- run:
name: Check version
command: |
pr_number=$(
echo $CIRCLE_PULL_REQUEST | sed -E "s/.+\/([0-9]+)$/\1/g"
)
if [[ -n ${pr_number} ]]; then
curl -L "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" -o jq
chmod +x jq
url="https://api.github.com/repos/developmentseed/collecticons-processor/pulls/$pr_number?access_token=$GITHUB_TOKEN"
target_branch=$(
curl "$url" | ./jq '.base.ref' | tr -d '"'
)
if [ "${target_branch}" == "${PRODUCTION_BRANCH}" ]; then
package_version=$(
cat package.json | ./jq '.version'
)
echo $package_version
git tag --list | egrep -c '^v${package_version}$'
version_exists=$(
git tag --list | egrep -c '^v${package_version}$'
)
# echo $version_exists
# if [[ $version_exists -eq 0 ]]; then
# echo "Version ($package_version) is ok";
# else
# echo "Version ($package_version) already exists";
# exit 1
# fi
else
echo "Not targetting ${PRODUCTION_BRANCH} branch"
fi
fi
workflows:
version: 2
only_test:
jobs:
- test
- check_version
9 changes: 9 additions & 0 deletions b.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package_version=$(
cat package.json | jq '.version'
)
echo $package_version

version_exists=$(
git tag --list | egrep -c '^v${package_version}$'
)
echo $version_exists

0 comments on commit c436417

Please sign in to comment.