I want to deploy the dist folder after success. But instead, it keeps deploying the whole repository.
What I want to achieve is the same effect with:
npm publish dist
Here is the related part from my .travis.yml:
deploy:
provider: npm
email: sa.alemdar#hotmail.com
api_key:
secure: MyApiKey
skip_cleanup: true
file_glob: true
file: "dist/**/*"
on:
tags: true
repo: salemdar/angular2-cookie
The solution is to use before_deploy script and go to your folder.
Just make sure you have include your package.json in your folder and skip_cleanup option to true.
There is a fonctional solution:
language: node_js
node_js:
- '5'
- '4'
after_success:
- npm run build #make a dist folder
before_deploy:
- cd dist
deploy:
provider: npm
email: email#gmail.com
skip_cleanup: true
api_key:
secure: ##your_secure_key
on:
branch: master
tags: true
repo: loveindent/stateful-api-mock-server
Related
I have created this yam file to create a binary image for my iot board with circle ci..
version: 2.1
orbs:
python: circleci/python#1.4.0
jobs:
build:
executor: python/default
steps:
- checkout # checkout source code to working directory
- run:
name: Install PlatformIO
command: pip install --upgrade platformio
- run:
name: Compile Project
command: pio run
- run:
name: Creating Dummy Artifacts
command: |
cd .pio/build/esp32dev
echo "firmare.bin" > /tmp/art-1;
mkdir /tmp/artifacts;
echo "my artifact files in a dir" > /tmp/artifacts/art-2;
- store_artifacts:
path: /tmp/art-1
destination: artifact-file
- store_artifacts:
path: /tmp/artifacts
workflows:
main:
jobs:
- build
I would like to store the artifact the firmware.bin in a bucket in aws...
Do you know how to do it or a similar example that I can check and modify ?
Thanks a lot
I guess the simple option is to use CircleCI's circleci/aws-s3 orb.
I've set a GitHub action that make a build of my React application.
I need that build to be pushed to another repo that I'm using to keep track of the builds.
This is the action that is actually running:
on:
push:
branches: [master]
jobs:
build:
name: create-package
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14]
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
name: Use Node.js 14
with:
node-version: ${{ matrix.node-version }}
#- name: Install dependencies
- run: npm ci
- run: npm run build --if-present
env:
CI: false
copy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Copy to another repo
uses: andstor/copycat-action#v3
with:
personal_token: ${{ secrets.API_TOKEN_GITHUB }}
src_path: build
dst_path: /.
dst_owner: federico-arona
dst_repo_name: test-build
dst_branch: main
By the way when the action run the copy job it fails with the following message:
cp: can't stat 'origin-repo/build': No such file or directory
What am I doing wrong?
For anyone that needs an answer on this.
The problem was related to the fact that I was using two different jobs, one to run the build and one to copy that build to another repo.
This won't work because each job has its own runner and its own file system, meaning that the data aren't shared between jobs.
To avoid this problem I made all on in one job. Another solution is to pass the build between jobs as artifact:
https://docs.github.com/en/actions/guides/storing-workflow-data-as-artifacts#passing-data-between-jobs-in-a-workflow
Another problem was related to the copy action I was using. For some reason that action didn't find the build directory, probably because its assuming a different working directory. I switched to another action.
Here's the final result:
on:
push:
branches: [master]
jobs:
build:
name: create-package
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14]
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
name: Use Node.js 14
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
env:
CI: false
- run: ls
- name: Copy to another repo
uses: andstor/copycat-action#v3
with:
personal_token: ${{ secrets.API_TOKEN_GITHUB }}
src_path: build
dst_path: /.
dst_owner: federico-arona
dst_repo_name: test-build
dst_branch: main
Having trouble deploying to HEROKU with CircleCI. I have already tested deploying git push heroku master to heroku manually, which is working. However when I use CircleCI, deployment no longer works.
Github repo url: https://github.com/dulerong/vue-test-circleci
I have set HEROKU environment variables in CircleCI project setting.
HEROKU_API_KEY=my_key
HEROKU_APP_NAME=my_app_name
Error message follows.
#!/bin/bash -eo pipefail
if false;then
force="-f"
fi
heroku_url="https://heroku:$HEROKU_API_KEY#git.heroku.com/$HEROKU_APP_NAME.git"
if [ -n "$CIRCLE_BRANCH" ]; then
git push $force $heroku_url $CIRCLE_BRANCH:main
elif [ -n "$CIRCLE_TAG" ]; then
git push $force $heroku_url $CIRCLE_TAG^{}:main
else
echo "No branch or tag found."
exit 1
fi
fatal: Not a git repository (or any of the parent directories): .git
Exited with code exit status 128
CircleCI received exit code 128
Below is my circleCI config.yml
version: 2.1
orbs:
heroku: circleci/heroku#1.2.5
jobs:
build-job:
working_directory: ~/repo
docker:
- image: circleci/node:12.18.2
steps:
- checkout
- run:
name: Install dependencies
command: npm install
- run:
name: Build
command: npm run build
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- run:
name: lint
command: npm run lint
- run:
name: test
command: npm run test:unit
deploy-job:
working_directory: ~/repo
docker:
- image: circleci/node:12.18.2
steps:
- attach_workspace:
at: ~/repo
- heroku/deploy-via-git
workflows:
version: 2.1
deploy:
jobs:
- build-job
- deploy-job:
requires:
- build-job
filters:
branches:
only: master
I have linked CircleCI to my Github repo
I have created .circleci folder config.yml
I have created an app on heroku, which works when I deploy manually
The build part of my CircleCI works, however deployment does not work
Any help is appreciated, thanks in advance.
Found out what I was missing.
- checkout
I was missing this line of code in my deploy-job. Hence after changing the deploy-job yml config code to following, everything worked.
deploy-job:
working_directory: ~/repo
docker:
- image: circleci/node:12.18.2
steps:
- checkout<--- INSERT THIS CODE HERE!!!!
- attach_workspace:
at: ~/repo
- heroku/deploy-via-git
Reason: checkout command leads CircleCI to the root directory of your project. Hence without this line of code, you're looking at a folder directory that's not even the root of your project.
Other useful command include
- run:
name: show directory
command: pwd
- run:
name: look in directory
command: ls -ltr
If you place those commands beneath checkouk, and look into the job progress in your CircleCI project, you can actually see which directory CircleCI is looking at, during that exact moment, very useful to check which directory CircleCI is working in. I put in those two commands and found out that my CircleCI was not looking at the root directory, hence discovering my problem.
Took me a few hours to figure this out!!!
I am trying to install npm with nvm using ansible playbook script on Ubuntu 18.04.2 LTS. It is getting installed but on running npm install command it returning an error ["/bin/bash: npm: command not found"]
this is the script
- name: Create destination dir if it does not exist
file:
mode: 0775
path: "/usr/local/nvm"
state: directory
when: "nvm_dir != ''"
- name: Install NVM
shell: "curl https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | NVM_SOURCE="" NVM_DIR=/usr/local/nvm PROFILE=/root/.bashrc bash"
args:
warn: false
register: nvm_result
This is the repository where I get the code (https://github.com/morgangraphics/ansible-role-nvm)
By default shell module uses /bin/sh unless the executable has been explicitly defined in the module using args/keyword.
Seems like /bin/bash(a variation of shell is not is installed on the host) thereby giving error. Script needs bin/bash.
bin/bash is mostly installed on all the operating systems. May be some path issue.
Also updated the code below with condition.
---
- hosts: localhost
tasks:
- name: Create destination dir if it does not exist
file:
mode: 0775
path: "/usr/local/nvm"
state: directory
when: "nvm_dir is not defined"
- name: Install NVM
shell: 'curl https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | NVM_SOURCE="" NVM_DIR=/usr/local/nvmPROFILE=/root/.bashrc bash'
args:
warn: false
register: nvm_result
I have a new issue with a Travis build. In brief, my .travis.yml file contains:
deploy:
provider: s3
access_key_id: mYacc3ssKeyID
secret_access_key:
secure: mYacc3ssKey
bucket: my-bucket-staging
skip_cleanup: true
local_dir: dist/
acl: public_read
on:
branch: staging
deploy:
provider: s3
access_key_id: mYOtheracc3ssKeyID
secret_access_key:
secure: mYOtheracc3ssKey
bucket: my-bucket
skip_cleanup: true
local_dir: dist/
acl: public_read
on:
branch: master
Until August 16, this setup worked as intended (staging branch was deployed to the my-bucket-staging bucket, master branch was deployed to the my-bucket bucket, and all other branches were ignored). My .travis.yml file hasn't changed since July 13, but the staging branch stopped deploying with the message Skipping a deployment with the s3 provider because this branch is not permitted on August 16. My last known successful deployment was on August 15.
It's also worth noting that the master deployment still works as expected, it's just the staging branch I'm having issues with.
Since I haven't changed anything on my end (the staging branch is the same branch, .travis.yml file is the same, etc), I'm wondering if there was a change with Travis that I missed? Does anyone know why this would (seemingly) just stop working?
I reread through Travis's documentation and didn't notice anything different, but I feel like something must have changed at some point or I'm missing something terribly obvious.
The above YAML segment defines two identical keys deploy, so only the last one is effective; meaning, there is no deployment provider defined with on.branch: staging as far as your .travis.yml is concerned.
If you want to define 2 deployment providers that work on different branches, you need a 2-element array under deploy:
deploy:
- provider: s3
access_key_id: mYacc3ssKeyID
secret_access_key:
secure: mYacc3ssKey
bucket: my-bucket-staging
skip_cleanup: true
local_dir: dist/
acl: public_read
on:
branch: staging
- provider: s3
access_key_id: mYOtheracc3ssKeyID
secret_access_key:
secure: mYOtheracc3ssKey
bucket: my-bucket
skip_cleanup: true
local_dir: dist/
acl: public_read
on:
branch: master
It is not clear to me how it could have been working before with your original configuration as indicated. I would be interested to see the working Travis CI build log.