Deploying to Payara Cloud from a GitHub Action Workflow
Published on 05 Sep 2022by Patrik Duditš
Payara Cloud provides an easy-to-use user interface to allow your application to run in a managed cloud environment. While this is very convenient for configuration and troubleshooting work, integration in continuous deployment pipelines calls for something else.
Our answer is deploying to Payara Cloud using a GitHub Action Workflow and Payara Cloud Command Line (PCL).
What is Payara Cloud?
Payara Cloud is a serverless solution, where infrastructural tasks related to cloud are managed for you. You simply select your WAR, click deploy, and you are running in the cloud. The software takes the user’s WAR file, packages it into a Docker image with Payara Micro – our microservices runtime – and completes all YAML, builds container images, creates a pod, deploys it on Kubernetes, updates the API server to manage ingress on Microsoft Azure and even creates an SSL certificate for the application. Find out more about how it workshere.
Integrating Payara Cloud Into Your CI/CD
You can find monitoring and configuration options in the user interface of Payara Cloud. However, you may not want to configure via this user interface each time if you are dealing with automated workflows.
This is why, in addition to the user interface, we have made it possible to control deployment and configuration of applications running in Payara Cloud withPCL – Payara Cloud Command Line. In this article we look at how to use it and the most common commands to use in deployment pipeline script.
The tool is distributed via Maven repositoryPayara Artifactseither asexecutable jarfile orzip file with binary and documentation. In a shell script PCL can be downloaded by using an approach similar to this:
-o pcl.zip && unzip pcl.zip && rm pcl.zip
This downloads the full package, extracts it and sets variable $PCL to point to PCL binary.
Payara Cloud Comand Line is an executable JAR file and requires at least the Java 8 development kit to be present in the environment it should run in. The binary we pointed to in a previous step is just a shell wrapper for executing java.
As a user, you authenticate using a browser. Deployment script obviously cannot do that. Instead, you login once via command PCL login and get a token which the script will use as its identity. The entire process is described in detail in PayaraCloud's documentation, the command line interaction will look like this:
# Uncomment when you're using Cloud Trial instance:
$PCL login --print-token
[INFO] In order to log in follow following link: https://login.payara.cloud/activate
[INFO] Your confirmation code is CVJF-XKGH
[SUCCESS] Token for environment-based login:
The output of the script represents the environment variable you would need to provide to your deployment pipeline so that script can assume your identity.
Deploying an Application
Since this is continuous deployment set up, let's assume the namespace for our application already exists, that the application was already deployed once and its current configuration is also valid for the new version being deployed.
In this example let's assume we're deploying to namespace start-dev, which is created by default for every subscriber, and that our application binary is created in
$PCL upload -n start-dev target/app.war --deploy
[UPDATE] State of inspection process is DEPLOYING
[UPDATE] State of deployment process is DEPLOYING
[UPDATE] State of deployment process is DEPLOYED
[SUCCESS] Deployment completed
Deploying to Payara Cloud via GitHub Actions Workflow
Let's put all the steps together into a GitHub actions workflow.
As a first step, obtain the CLI token as described above, and set that into your repository's secrets:
Then, create the workflow under directory
.github/workflows/ such as this one:
name: Deploy to Payara Cloud
branches: [ main ]
# if using Payara Cloud Trial, set this:
# PCL_ENDPOINT: https://manage.trial.payara.cloud
# token obtained from `pcl login --print-token`
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Cache repository
- name: Build with Maven
run: mvn -B verify
- name: Download PCL
# This should download PCL from official download location rather than our internal Maven repo
# unzip cannot do pipes. jar can, but it ignores file permissions
curl https://nexus.payara.fish/repository/payara-artifacts/fish/payara/cloud/pcl/$PCL_VERSION/pcl-$PCL_VERSION.zip -o pcl.zip
- name: Deploy application
$PCL upload -n start-dev target/app.war --deploy
And there we have it! Now on every push to branch
main the application will be rebuilt and deployed into your Payara Cloud namespace.
Like What You See? Payara Cloud is Coming Soon
Payara Cloud will be launching soon - offering a serverless option for running your Jakarta EE apps on the cloud!
Download the Datasheet to find out more orregisterto be the first in the know: