I am using Circleci to build and test typescript code. when code is pushed and Circleci starts building in a docker container, I noticed it ignores some hidden files (dot files) in the repository while copying to the container. I ensured that by adding ls
command in one of steps. How to make Circleci copy .env
from the code repository while copying the rest of the code files?
.circleci/config.yml
version: 2 # use CircleCI 2.0
jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
working_directory: ~/su-app-api # directory where steps will run
docker: # run the steps with Docker
- image: node:16-alpine3.16
steps: # a collection of executable commands
- checkout # special step to check out source code to working directory
- add_ssh_keys:
fingerprints:
- "my finger print"
- run:
name: ls
command: ls -al && ls api -al
- run:
name: Install API Dependencies
command: npm i
- run:
name: Build API
command: npm run build:api
- run:
name: Test API
command: npm run test
- deploy:
name: deployment
command: ssh -o "StrictHostKeyChecking no" user_name@ip "cd ~/su-app-api && git pull origin deploy && sh deploy.sh"
I found the problem. I was using the node-alpine
image which has no shh-client or git installed. As a result, the checkout step in Circleci was falling back to CircleCI's native git client¹ but the behavior may be different from official git.
I added a step to install ssh and git before the checkout step and it worked normally.
- run:
name: install ssh and git
command: apk add --update openssh-client git