Automatic deploy from gitlab to heroku - node.js

Hi guys i was wondering if it is possible to make automatic deploys from gitlab to heroku (react app), right now this is my gitlab-ci
image: node:8.10.0-alpine
cache:
key: "alpine"
paths:
- node_modules/
before_script:
- npm install
build:
stage: build
artifacts:
paths:
- dist/
script:
- npm run build
only:
- master
tags:
- docker
is there a way to push the builded proyect to heroku?

Related

How to create CI/CD pipeline for NextJS app with .yml and gitlab?

I followed a tutorial on youtube Link to create a ci/cd pipeline for deployment on netlify.
The builds are successful but the deploy shows a 404 page.
Link to deployed site
I'm posting the yml commands below
stages:
- lint
- build
- deploy
lint project:
stage: lint
image: node:15
script:
- npm install
- npm run lint
build project:
stage: build
image: node:15
script:
- npm install
- npm run build
artifacts:
paths:
- .next
netlify:
stage: deploy
image: node:15
script:
- npm set prefix ~/.npm; path+=$HOME/.npm/bin
- path+=./node_modules/.bin
- npm install -g netlify-cli
- netlify deploy --dir=.next --prod
I'm trying to create a Next JS boilerplate to be used in my future projects & Through CI/CD pipeline i'm looking for automated deployment. Any help or link to resources would be appreciated.

cypress record video did not work in gitlab-ci

since migrating our test from bitbucket to gitlab the video is no longer recorded during runs in the pipeline. has anyone encountered a similar problem? cypress version 7.3.0
stages:
- build
- test
variables:
npm_config_cache: "$CI_PROJECT_DIR/.npm"
CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/cache/Cypress"
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cache/*
- cache/Cypress
- node_modules
- build
image: cypress/browsers:node14.15.0-chrome86-ff82
stage: build
script:
- yarn install
- npx cypress cache path
- npx cypress cache list
phone-sanity-tests-development:
image: cypress/browsers:node14.15.0-chrome86-ff82
stage: test
parallel: 15
script:
- yarn cypress:run-phone-development-sanity
artifacts:
paths:
- cypress/screenshots/**
- cypress/videos/**
- cypress/reports/**
- cypress/projects/phone/puppeteer/videos/**
Here: - yarn cypress:run-phone-development-sanity you need to add --record.
In order to tell cypress to record and make screenshots you need to configure this on the run command in yml file.
This link is nice example how Cypress team configures their gitlab-ci.yml:
https://github.com/cypress-io/cypress-realworld-app/blob/develop/.gitlab-ci.yml

Gitlab CI/CD not triggering the job

I have a React app (using Create React App) that I want to deploy to Heroku.
For that I am trying to use GitLab CI/CD
Here is the code inside .gitlab-ci.yml
image: node:latest
before_script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
stages:
- staging
- production
staging:
type: deploy
stage: staging
image: ruby:latest
script:
- dpl --provider=heroku --app=$DEV_APP_NAME --api-key=$HEROKU_API_KEY
only:
- develop
production:
type: deploy
stage: production
image: ruby:latest
script:
- dpl --provider=heroku --app=$STAGING_APP_NAME --api-key=$HEROKU_API_KEY
only:
- master
I am trying to use shared runner and I have not added any specific runner. I have left the runner configuration to default as to what it was when I created my repo.
Even if I push to my repo on master or develop branch it is not triggered.

Cache files are gone in my GitLab CI pipeline

I'm trying to setup GitLab CI for a mono repository.
For the sake of the argument, lets say I want to process 2 JavaScript packages:
app
cli
I have defined 3 stages:
install
test
build
deploy
Because I'm reusing the files from previous steps, I use the GitLab cache.
My configuration looks like this:
stages:
- install
- test
- build
- deploy
install_app:
stage: install
image: node:8.9
cache:
policy: push
paths:
- app/node_modules
script:
- cd app
- npm install
install_cli:
stage: install
image: node:8.9
cache:
policy: push
paths:
- cli/node_modules
script:
- cd cli
- npm install
test_app:
image: node:8.9
cache:
policy: pull
paths:
- app/node_modules
script:
- cd app
- npm test
test_cli:
image: node:8.9
cache:
policy: pull
paths:
- cli/node_modules
script:
- cd cli
- npm test
build_app:
stage: build
image: node:8.9
cache:
paths:
- app/node_modules
- app/build
script:
- cd app
- npm run build
deploy_app:
stage: deploy
image: registry.gitlab.com/my/gcloud/image
only:
- master
environment:
name: staging
url: https://example.com
cache:
policy: pull
paths:
- app/build
script:
- gcloud app deploy app/build/app.yaml
--verbosity info
--version master
--promote
--stop-previous-version
--quiet
--project "$GOOGLE_CLOUD_PROJECT"
The problem is in the test stage. Most of the time the test_app job fails, because the app/node_modules directory is missing. Sometimes a retry works, but mostly not.
Also, I would like to use two caches for the build_app job. I want to pull app/node_modules and push app/build. I can't find a way to accomplish this. This makes me feel like I don't fully understand how the cache works.
Why are my cache files gone? Do I misunderstand how GitLab CI cache works?
The cache is provided on a best-effort basis, so don't expect that the cache will be always present.
If you have hard dependencies between jobs, use artifacts and dependencies.
Anyway, if it is just for node_modules, I suggest you to install it in every step, instead of using artifacts - you will not save much time with artifacts.

GitLab CI: configure yaml file on NodeJS

I have problem with test scss-lint in my project on nodejs.
When tests reach scss-lint, it gives an error.
How to make sure that tests do not fall with the successful result of the test itself?
My gitlab-ci.yml
image: node:wheezy
cache:
paths:
- node_modules/
stages:
- build
- test
gem_lint:
image: ruby:latest
stage: build
script:
- gem install scss_lint
artifacts:
paths:
- node_modules/
only:
- dev
except:
- master
install_dependencies:
stage: build
script:
- npm install
artifacts:
paths:
- node_modules/
only:
- dev
except:
- master
scss-lint:
stage: test
script:
- npm run lint:scss-lint
artifacts:
paths:
- node_modules/
only:
- dev
except:
- master
You are doing it wrong.
Each job you define (gem_lint, install_dependencies, and scss-lint) is run with its own context.
So your problem here is that during the last step, it doesn't find the scss-lint gem you installed because it switched its context.
You should execute all the scripts at the same time in the same context :
script:
- gem install scss_lint
- npm install
- npm run lint:scss-lint
Of course for this you need to have a docker image that has both npm and gem installed maybe you can find one on docker hub), or you can choose one (for example : ruby:latest) and add as the first script another one that would install npm :
- curl -sL https://deb.nodesource.com/setup_6.x | bash -

Resources