Continuous Deployment of a electron app using GitLab - gitlab

I am developing a desktop app on a Linux machine. The code is hosted on GitLab.com. I'd like a sample gitlab-ci.yml on building the app for Windows. I'm out of ideas on how to go about this, any assistance will be appreciated.

The build steps depends on the library you are using to build the electron app. Here is a sample using electron-builder
// .gitlab-ci.yml
stages:
- build
build:
image: electronuserland/builder:wine
stage: build
script:
- yarn
- yarn dist:win
artifacts:
expire_in: 30 days
paths:
- ./dist/
only:
- master
// package.json
{
...
"scripts": {
...
"dist:win": "electron-builder -w",
}
}

I feel this question is more related to electron itself rather than GitLab CI. In the runner config you perform all tasks you'd normally perform while developing the app locally. So you should put all the stuff you usually put into your build tasks locally into the CI config.

Related

How to deploy war file on two instance of tomcat using gitlab CI/CD?

I have a spring boot web app project on gitlab, which is needed to be deployed on two remote instances of Tomcat servers using CI/CD. After quick research I have found this article. According to the article all necessary components are installed and the following gitlab-ci.yml file was created:
stages:
- build
- deploy
maven-build:
stage: build
script: "mvn package -B"
artifacts:
paths:
- target/*.war
Deploy:
stage: deploy
script:
- cp /home/gitlab-runner/builds/76XAQ_K8/0/l.furkat/testservice/target/testservice.war /var/lib/tomcat9/webapps
But in the script above one can deploy the app on one instance.
How can I deploy the project on two instances?
Any hint or navigation is appreciated.

How to deploy Angular App with GitLab CI/CD

I've been trying to setup a CI/CD Pipeline on my Repo which runs common tasks like linting/tests etc. I've successfully setup a Gitlab-Runner which is working fine. The only part I'm stuck is the "deploy" part.
When I run my build, how do I actually get the files into my /var/www/xyz folder.
I get that everything is running in a Docker Container and I can't just magically copy paste my files there, but i don't get how I get the files on my actual server-directory. I've been searching for days for good docs / explanations, so as always, StackOverflow is my last resort for help.
I'm running on a Ubuntu 20.04 LTS VPS and a SaaS GitLab-Repository if that info is needed. That's my .gitlab-ci.yml:
image: timbru31/node-alpine-git
before_script:
- git fetch origin
stages:
- setup
- test
- build
- deploy
#All Setup Jobs
Install Dependencies:
stage: setup
interruptible: true
script:
- npm install
- npm i -g #nrwl/cli
artifacts:
paths:
- node_modules/
# All Test Jobs
Lint:
stage: test
script: npx nx run nx-fun:lint
Tests:
stage: test
script: npx nx run nx-fun:test
Deploy:
stage: build
script:
- ls /var/www/
- npx nx build --prod --output-path=dist/
- cp -r dist/* /var/www/html/neostax/
only:
refs:
- master
Normally I would ssh into my server, run the build, and then copy the build to the corresponding web-directory.
TL;DR - How do I get files from a GitLab-Runner to an actual directory on the server?

Firebase deploy works in the console but not in bitbucket pipeline

I'm trying to deploy my webapp to firebase hosting through a bitbucket pipeline, It's not deploying correctly in the pipeline but in the console it works no problem. This is what I do in the console:
npm run build
firebase login:ci
firebase deploy --project $PROJECT_NAME
In the pipeline I'm running this YAML script:
image: node:10.15.3
pipelines:
default:
- step:
name: Install and Build App
caches:
- node
script:
- npm install
- CI=false npm run build
artifacts:
- build/
- step:
name: Deploy App to Firebase
deployment: production
script:
- pipe: atlassian/firebase-deploy:0.6.0
variables:
KEY_FILE: $KEY_FILE
PROJECT_ID: $PROJECT_ID
I think it might have to do with the .firebaserc but I'm not sure. this is the .firebaserc:
firebase target:apply hosting $PROJECT_ID $DOMAIN
Maybe someone can shed some light on why this isn't working, I'm new to pipeline scripts and I don't really see the issue, it succeeds in deploying to firebase hosting but It's not working at all on the actual domain.
When you run the command firebase login:ci that should generate a TOKEN, you add that token in Bitbucket in your Repository Settings > Repository Variables. What ever name you choose should match your pipeline. In my example I use FIREBASE_TOKEN_CI. When I commit my changes to bitbucket, it runs the pipeline, builds and deploys.
You can always modify your script in your package.json so in your cli you can run npm run build:prod like you would run npm run start, etc and use the build:prod in the yml.
here is an example:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build:prod": "ng build --prod=true"
}
CODE BELOW is a pipeline.yml I use for Ionic/Angular
NOTE: Artifacts is the folder your build files are generated after running build. Angular is called dist, so you might use dist/. My example uses www/** that is Ionics build output. You have some CI=False in your example, I have not seen that nor use that and my project builds and deploys. My second script is for cloud functions
- cd functions
- npm install
- cd ..
you can omit that part if you don't have functions. I have recently had a error about OAuth and I had to generate a new token with login:ci and replace my token, and it was working again for deploy. Hope this helps anyone. I had problems at first also and found a working format that I can adapt to other frameworks.
image: node:10.15.3
pipelines:
default:
- step:
name: Install, Build
caches:
- node
deployment: test
script:
- npm install
- npm run build:prod
artifacts:
- www/**
- step:
name: Deploy to Firebase
deployment: production
script:
- cd functions
- npm install
- cd ..
- pipe: atlassian/firebase-deploy:0.3.4
variables:
FIREBASE_TOKEN: '$FIREBASE_TOKEN_CI'

Gitlab-runner run too long

I made a static site and now trying to configure GitLab CI/CD.
The source code for the site is on a remote server.
This is my gitlab-ci.yml
image: ruby:2.6
variables:
JEKYLL_ENV: production
before_script:
- gem install bundler
- bundle install
deploy:
stage: deploy
script:
- bundle exec jekyll build --watch
only:
- master
I use --watch because without using --watch job passed correctly, changes are displayed on the local computer, but no updates are displayed on the remote server.
There is a line in the answer:
Auto-regeneration: disabled for '/ builds / wiki / docplus'. Use --watch to enable
But with --watch I push my commits and gitlab-runner runs too long and job failed
$ bundle exec jekyll build --watch
Configuration file: /builds/wiki/docplus/_config.yml
Source: /builds/wiki/docplus
Destination: /builds/wiki/docplus/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 1.863 seconds.
Auto-regeneration: enabled for '/builds/wiki/docplus'
Pulling docker image gitlab/gitlab-runner-helper:x86_64-003fe500 ...
ERROR: Job failed: execution took longer than 1h0m0s seconds
What's wrong?
Update your deploy.script to just build (without --watch):
deploy:
stage: deploy
script:
- bundle exec jekyll build

Problem to run nodejs app on Gitlab Pages

I'm trying to run my nodejs app on gitlab pages. I use a gitlab-ci.yml file for this where I deploy and run the nodejs app. Unfortunately the pipeline kills the process after 1 hour because the pipeline thinks running the nodejs app is part of the build script. I have two questions:
- Can you run a nodejs app on gitlab pages?
- If so, what is the best way to start the app?
Below you find the gitlab-ci.yml file.
Thanks!
image: node:latest
stages:
- build
cache:
paths:
- node_modules/
install_dependencies:
stage: build
script:
- npm install
- npm install -g nodemon
- NODE_ENV=production nodemon app.js
artifacts:
paths:
- node_modules/
Can you run a nodejs app on gitlab pages?
No! Gitlab pages allow you to host only static websites: https://about.gitlab.com/product/pages/
If so, what is the best way to start the app?
If your app is static, try to use a static site generator! If you wanna play with nodejs, try other hosting platforms like heroku or clever cloud

Resources