Issue with circleci and heroku with react app - heroku

My CI/CD is: git > cicleci > heroku
I'm using circleci's suggested configuration (attached below)
I have the proper environment variable in circleci.
The first part is working well, however, when I deploy to heroku I can see warnings from devs dependencies like:
./src/hooks/myHook.js
Line 11: React Hook useEffect has a missing dependency: 'x'. Either include it or remove the dependency array react-hooks/exhaustive-deps
which makes me think that React dev is running.
Can anyone help me?
version: 2
jobs:
build:
...
deploy:
docker:
- image: buildpack-deps:trusty
steps:
- checkout
- run:
name: Deploy Master to Heroku
command: |
git push https://heroku:$HEROKU_API_KEY#git.heroku.com/$HEROKU_APP_NAME.git master
workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master

I'm not sure if you are already but I highly recommend using this Heroku buildpack rather than the standard Heroku Node buildpack: https://github.com/mars/create-react-app-buildpack. This buildpack starts in production by default.
In Heroku go to settings > Buildpacks and click on the Add buildpack, then enter the following url: https://github.com/mars/create-react-app-buildpack.git and save.
However if there is a hook error as above I would fix that issue by adding it into the dependency array in the hook.

Related

How to build, deploy and execute dotnet library on Heroku

I have .net core 2.1 project library which executes db migrations (using the fluentmigrator). What is the simplest method to to execute this library once I push my code changes (migrations) to github master branch? I was trying to define below yml file and procfile but there is error after the build on release command I have an error:
/bin/sh: 1: dotnet: not found
How to make possible to build and run .net core app using buildpack. Is it possible without using docker?
name: Deploy to Heroku
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
defaults:
run:
working-directory: ./app.db/
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: akhileshns/heroku-deploy#v3.7.8
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "app-db"
heroku_email: "myemail"
buildpack: "https://github.com/jincod/dotnetcore-buildpack"
appdir: "app.db"
Procfile
release: cd $HOME/heroku_output && dotnet app.db.dll
Yes, heroku dyno is a standard ubuntu (18.04 - 20.04 it depends on stack).
Our team used own buildpack and own build script.
HVG/self-buildpack:
https://github.com/HVG/self-buildpack
Sample Asp.Net Core project:
https://gist.github.com/felegy/8834d26063204d129a7b2893a91f6627

Using Travis Ci with GitHub Pages Error: gh-token is invalid

I'm setting up my Travis Ci integration with my GitHub pages repo and I'm getting this error when committing to my dev branch, which on completion should automatically commit to my master branch.
My Error:
gh-token is invalid. Details: GET https://api.github.com/user: 401 - Bad credentials // See: https://developer.github.com/v3
My git flow is as follows:
I use dev as an intermediary branch. The application is using vue.js and required a production build, which the production build is what should be pushed to master.
push local branch to remote branch
create a pull request on remote feature branch to the dev branch
merge feature branch with dev branch (this is when Travis CI should push to master)
Here is my current .travis.yml
if: branch = dev
language: node_js
node_js:
- "lts/*"
cache:
directories:
- "node_modules"
script:
- set -e
- npm run build
deploy:
provider: pages
skip_cleanup: true
github_token: GITHUB_TOKEN
keep_history: true
local_dir: build
target_branch: master
on:
branch: dev
I've confirmed my GitHub access token and tried increasing permissions. The token I'm currently using only has public repo access, which is based on the Travis CI docs
Might be an easy fix.
Have you tried access GITHUB_TOKEN like an environment variable?
github_token: $GITHUB_TOKEN

CircleCI 2.0 Workflow - Deploy not working

I'm trying to set up a workflow in CircleCI for my React project.
What I want to achieve is to get a job to build the stuff and another one to deploy the master branch to Firebase hosting.
This is what I have so far after several configurations:
witmy: &witmy
docker:
- image: circleci/node:7.10
version: 2
jobs:
build:
<<: *witmy
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run:
name: Build app in production mode
command: |
yarn build
- persist_to_workspace:
root: .
deploy:
<<: *witmy
steps:
- attach_workspace:
at: .
- run:
name: Deploy Master to Firebase
command: ./node_modules/.bin/firebase deploy --token=MY_TOKEN
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
The build job always success, but with the deploy I have this error:
#!/bin/bash -eo pipefail
./node_modules/.bin/firebase deploy --token=MYTOKEN
/bin/bash: ./node_modules/.bin/firebase: No such file or directory
Exited with code 1
So, what I understand is that the deploy job is not running in the same place the build was, right?
I'm not sure how to fix that. I've read some examples they provide and tried several things, but it doesn't work. I've also read the documentation but I think it's not very clear how to configure everything... maybe I'm too dumb.
I hope you guys can help me out on this one.
Cheers!!
EDITED TO ADD MY CURRENT CONFIG USING WORKSPACES
I've added Workspaces... but still I'm not able to get it working, after a loooot of tries I'm getting this error:
Persisting to Workspace
The specified paths did not match any files in /home/circleci/project
And also it's a real pain to commit and push to CircleCI every single change to the config file when I want to test it... :/
Thanks!
disclaimer: I'm a CircleCI Developer Advocate
Each job is its own running Docker container (or VM). So the problem here is that nothing in node_modules exists in your deploy job. There's 2 ways to solve this:
Install Firebase and anything else you might need, on the fly, just like you do in the build job.
Utilize CircleCI Workspaces to carry over your node_modules directory from the build job to the deploy job.
In my opinion, option 2 is likely your best bet because it's more efficient.

Circleci task job never executer

I'm having the following circleCi config :
version: 2
jobs:
build:
machine: true
branches:
ignore: gh-pages
steps:
- run: echo "Skipping tests on gh-pages branch"
deployment:
machine:
node:
version: 6.11.2
npm:
version: 3.10.10
branch: ci
steps:
- run: git config --global user.email "<GITHUB_USERNAME>#users.noreply.github.com"
- run: git config --global user.name "<YOUR_NAME>"
- run: echo "machine github.com login <GITHUB_USERNAME> password $GITHUB_TOKEN" > ~/.netrc
- run: cd website && npm install && GIT_USER=<GIT_USER> npm run publish-gh-pages
that aims to deploy a https://docusaurus.io/ site on my github page.
Actually, when the CI runs on the ci branch, it should run the deployment job.
Actually, the deployment job is never triggered and I don't understand why.
I'm well building my ci branch
Here's my circleci build :
This is not running correctly because the config you are using is completely incorrect. There's aspects of CircleCI 2.0 configuration and aspects of CircleCI 1.0 configuration.
I'd recommend choosing one platform (CircleCI 2.0) and then going through the configuration reference for that version. Here's the configuration reference for CircleCI 2.0: https://circleci.com/docs/2.0/configuration-reference/
Feel free to do that, come back and update your question, or post a question at https://discuss.circleci.com.
Respectfully,
Ricardo N Feliciano
Developer Evangelist, CircleCI

Deploying tagged builds from Travis-CI to Heroku

I am trying to get Travis-CI to automatically deploy a successful tagged build to Heroku. Below is my .travis.yml setup:
deploy:
provider: heroku
strategy: git
run:
- "rake db:migrate"
- restart
on:
tags: true
Upon tagging the repository:
git tag -a 1.0.0 -m "release 1.0.0"
and pushing to the remote repository, Travis-CI kicks off the build but exits immediately after the following:
$ git fetch --tags
Done. Your build exited with 0.
Travis-CI does not deploy the application to Heroku. Am I missing a piece?
There is currently a glitch with on: tags: true that the condition is never met and the code will never trigger a deploy. The github issue is here. The issue should be resolved soon, and in the meantime you can use a branch like releases to update your heroku app with on:branch.
Update:
To fix on:tags, you can do this, as refrenced in the above github issue.
on:
tags: true
all_branches: true

Resources