with GitHub Actions
In recent years, tools like Travis CI and CircleCI have set out to solve the problem behind the CI/CD building. Often confusing for devs who had to switch sites again and again, these tools created the need to be added to the repository page. Since 2019, GitHub Actions has support for CI/CD and now makes it easier to automate how we build, test, and deploy our projects. In this tutorial, we are going to build a CI/CD pipeline to deploy a Java application with TotalCross but you can use into your favorite framework/vanilla project. It's quite generic.
TotalCross is a cross-platform free open source GUI creator and will be very helpful for us in this tutorial. How about starting in just 8 minutes? See more about TotalCross, the fastest way to build GUI!
The next steps may be easier if you get TotalCross get started. After you create your Java with Maven project in any IDE of your choice and you upload the repository to GitHub, you only need to open the Actions dashboard:
Now let's set up our own workflow:
You can choose the name of your file. Let's call it
Right below we can edit our pipeline descriptor file.
I recommend copy and paste the following code:
name: Java CI with Maven on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Set up JDK uses: actions/setup-java@v1 with: java-version: 1.8 - name: Build with Maven run: mvn package - name: Archive results uses: actions/upload-artifact@v1 with: name: artifacts path: target/install
We need to talk about some lines to make it available to your customized options. Line-by-line:
||set the task title in the action pane|
||and its subsequent lines define the triggers for starting the task, is required|
||groups one or more tasks|
||it's our only task, you could call it by some other name like
||defines the host machine's operating system, with TotalCross you can generate applications for Windows, android, iOS and more|
||the next lines starting with
Let's take a closer look at the
usesa Marketplace action to checkout the project;
usesanother community action to install the JDK. The version can be changed on line 20;
- Runs the necessary command for Maven build. Switch to the command you already use on line 22, something like
mvn -B package --file pom.xml;
- The last step only exports the resulting artifacts. They can be used by other jobs. You can change the path to the artifacts on line 27.
We need to commit the changes:
Then we need to return to Actions:
Wait a few minutes until the work is finished and the artifacts are available:
Download the artifacts and test!
GitHub actions is a very powerful tool and is being improved very quickly, visit the documentation. Some interesting features are already available. For example you may have job related badges in the repository README.md:
You can also create jobs for Test and Publish your projects, your starting point can be
run commands (they behave like shell commands) or knowing some community actions like:
If you liked this article, please clap and share your comments below! Did you like the TotalCross project? Support us with a star!
Thanks a lot!