How To Build Github Actions CI/CD for Java App

How To Build Github Actions CI/CD for Java App

CI/CD is a continuous integration and continuous deployment. It is a tool used by DevOps engineers to automatically update the developer's code when there is a new push on Git Hub. There are many ways to build CI/CD. You can use Jenkins, circle ci, GitHub actions, etc. This time, you want to practice the use of GitHub action

Java programming language can be used to build both IOS and Andriod applications. One of the things I love about Java is its reliability and also being a general-purpose language.

This article will give you insight into how to build ci/cd for any Java app using GitHub actions. Every Java app code has the .graddlew file. When this file is located in your developer's code, you will have to give it the permission needed.

Create a workflow folder in your code, and create a yaml file in this folder. You can name it main.yaml. Copy the code below and paste it into the yaml file

name: Java CI with Maven

on:

push:

branches: [ "master" ]

pull_request:

branches: [ "master" ]

permissions: read-all

jobs:

build:

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2

- name: Set up Gradle

uses: gradle/gradle-build-action@v2

- name: Set Git user

run: |

git config user.email ""

git config user.name ""

- name: Change wrapper permissions

run: chmod +x ./gradlew

- name: Run build with gradle wrapper

run: ./gradlew

env:

GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}

Ensure that you use the branch that has your .gradlew file inside it. Input your git username and email address to the right place. Create an environment variable for your GitHub token. Click on the action and run your code. It should run successfully.

In this article, you learned the simplest way to build a CI/CD for a Java application.