Skip to content

Instantly share code, notes, and snippets.

@kidchenko
Last active September 4, 2019 02:10
Show Gist options
  • Save kidchenko/874b3f47f844a63dd557f364a2e16d0d to your computer and use it in GitHub Desktop.
Save kidchenko/874b3f47f844a63dd557f364a2e16d0d to your computer and use it in GitHub Desktop.
Codesanook #06
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:8-browsers
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4
working_directory: ~/repo/ci-start
steps:
- checkout:
path: ~/repo
# 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" }}
# buil!
- run: yarn build
# run tests!
- run: yarn test
# save dist folder!
- persist_to_workspace:
# Must be an absolute path, or relative path from working_directory. This is a directory on the container which is
# taken to be the root directory of the workspace.
root: ~/repo/ci-start
# Must be relative path from root
paths:
- build
deploy:
docker:
- image: buildpack-deps:trusty
working_directory: ~/repo/ci-start/build
steps:
- attach_workspace:
# Must be absolute path or relative path from working_directory
at: ~/repo/ci-start
- run:
name: git init
command: |
echo '{"root":"."}' > static.json
ls
git init
git config --global user.email "deploy@codesanook.com"
git config --global user.name "CircleCI Deploy"
git add -A
- run:
name: git commit
command: |
git add -A
git commit -m "Deploy"
- run:
name: Deploy Master to Heroku
command: |
git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master -f
workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master

Getting started

Requirements

Run these commands and install what do you not have

git --version

node --version

npm --version

yarn --version

Create an account on these services

  1. Create new repository sanook-meetup-006

    1. public
    2. Initialize with README
    3. gitignore Node
    4. Licence: MIT
  2. Clone your repository

    1. git clone https://github.com/YOUR_USERNAME/sanook-meetup-006.git
  3. Get the code

    1. git clone https://github.com/kidchenko/sanook-meetup-006.git
  4. Copy the ci-start folder to your repository

  5. Run yarn inside ci-start

  6. Commit and push

    1. git add :/
    2. git commit -m "Add source code"
    3. git push origin master
  7. Heroku https://github.com/heroku/heroku-buildpack-static

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment