DevShivmohan / Learning-everything

Learning for developer only
0 stars 1 forks source link

Github actions for deployement - on cloude server #22

Open DevShivmohan opened 2 years ago

DevShivmohan commented 2 years ago

Build and deployement spring boot project on cloude server


# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java deployment

on:
  push:
    branches: [ "dev" ]
  pull_request:
    branches: [ "dev" ]

jobs:

  deploy:
    runs-on: ubuntu-latest
    name: Deploy and run the JAR file on the remote server
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 17.0.4
        uses: actions/setup-java@v1
        with:
          java-version: 17.0.4
      - name: Build with Maven
        working-directory: ./security-server/
        run: mvn -B package --file pom.xml

      - name: copy file via ssh key
        uses: garygrossgarten/github-action-scp@release
        with:
          local: "./security-server/target/Transfer-files-1.0.jar"
          remote: "/home/shiv-projects/transfer-service/Security-services/security-server/Transfer-files-1.0.jar"
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}

      - name: Run a script on remote server (start the application)
        if: always()
        uses: fifsky/ssh-action@master
        with:
          command: |
            cd /home/shiv-projects/transfer-service/Security-services/security-server && java -jar Transfer-files-1.0.jar -xms200M -xmx768M &
          host: ${{ secrets.HOST }}
          user: ${{ secrets.USERNAME }}
          pass: ${{ secrets.PASSWORD }}
          args: "-tt"
DevShivmohan commented 2 years ago

Allocating heap memory at the starting of application

java -jar Spectrum-Admin.jar -xms400M -xmx800

Heap memory xmx and xms

The flag Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), while Xms specifies the initial memory allocation pool. This means that your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory. For example, starting a JVM like below will start it with 256 MB of memory and will allow the process to use up to 2048 MB of memory:

Example:- java -Xms256m -Xmx2048m -Xmx1024k -Xmx512m -Xmx8g

DevShivmohan commented 1 year ago

Artifact releases

- uses: actions/upload-artifact@v1
      with:
          name: report-release
          path: /home/runner/work/spectrum-admin/spectrum-admin/Backend/target

Where path is the file or directory path to release

Like this screenshot