Reputation: 69
I would like to have two circle ci config for two subfolders.
One is for q1, another is for q2. But I have no ideas how to set it up correctly.
I need to push the repo folder to GitHub.
Q1: Are working directory
and paths
in two config.yml
correct?
Q2: Are the folder structure correct?
(I think .circleci could not be placed inside subfolder, am i right? So where should i place them? And how to change the paths and working directory of them?)
My repo
folder structure is as below:
.
├── .gitignore
├── q1
│ ├── .circleci
│ │ └── config.yml
│ ├── node_modules
│ ├── package.json
│ └── yarn.lock
├── q2
│ ├── .circleci
│ │ └── config.yml
│ ├── node_modules
│ ├── package-lock.json
│ └── package.json
└── q3
My config.yml
for q1
is as below:
version: 2.1
jobs:
deploy:
working_directory: ~/repo/q1
docker:
- image: circleci/node:16.9
steps:
- checkout
path: ~/repo
- run:
name: install_node_modules
command: |
sudo yarn install
- run:
name: deploy
command: |
yarn run deploy
workflows:
version: 2
deploy:
jobs:
- deploy:
filters:
branches:
only: main
My config.yml
for q2
is as below:
version: 2.1
jobs:
build:
working_directory: ~/repo/q2
docker:
- image: circleci/node:16.9
steps:
- checkout
path: ~/repo
- run:
name: Update NPM
command: "sudo npm install -g npm"
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Install Dependencies
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- run:
name: Run tests
command: npm run test
Thank you.
Location of .circleci
folder: move to under repo
folder
version: 2.1
jobs:
deploy_q1:
working_directory: ~/repo/q1
docker:
- image: circleci/node:16.9
steps:
- checkout:
path: ~/repo
- run:
name: install_node_modules
command: |
sudo yarn install
- run:
name: deploy
command: |
yarn run deploy
test_q2:
working_directory: ~/repo/q2
docker:
- image: circleci/node:16.9
steps:
- checkout:
path: ~/repo
- run:
name: install_node_modules
command: |
sudo yarn install
- run:
name: Run tests
command: yarn test
workflows:
version: 2
deploy_q1_and_test_q2:
jobs:
- deploy_q1:
filters:
branches:
only: main
- test_q2:
filters:
branches:
only: main
Upvotes: 0
Views: 1312