This repository demonstrates a GitHub Actions workflow that builds a java gradle project and deploys the package using the github-actions-deploy custom action. This guide will walk you through the setup and functionality of the workflow.
This project is a Java Gradle project designed to demonstrate the use of GitHub Actions. The workflow defined in build-deploy.yml
performs the following steps:
- Checks out the code from the repository.
- Sets up JDK 17.
- Grants execute permissions to the Gradle wrapper script.
- Builds the project using Gradle.
- Creates, publishes, and deploys the package using
digital-ai/github-actions-deploy
.
The main workflow file, .github/workflows/build-deploy.yml
, is configured as follows:
name: Build and Deploy Package
on: [workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: Grant execute permissions to gradlew
run: chmod +x ./gradlew
- name: Build with Gradle
id: build
run: ./gradlew build --no-daemon --console=plain
- name: Create Publish and Deploy Package
id: deploy
uses: digital-ai/github-actions-deploy@v1.0.0-beta.1
with:
serverUrl: ${{ secrets.SERVERURL }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
manifestPath: '/deployit-manifest.xml'
action: 'create_publish_deploy'
outputPath: '/outputdar'
versionNumber: ${{ vars.VERSIONNUMBER }}
packageName: 'appForAction-1.0.dar'
environmentId: 'Environments/envForAction'
rollback: 'yes'
- Checkout code: Uses the
actions/checkout@v2
action to clone the repository. - Set up JDK 17: Uses the
actions/setup-java@v2
action to set up AdoptOpenJDK 17. - Grant execute permissions to gradlew: Runs a shell command to make the Gradle wrapper executable.
- Build with Gradle: Executes the Gradle build command.
- Create Publish and Deploy Package: Uses the
digital-ai/github-actions-deploy@main
action to create, publish, and deploy the package.
The workflow uses the following secrets and variables:
SERVERURL
: The URL of the deployment server.USERNAME
: The username for the deployment server.PASSWORD
: The password for the deployment server.VERSIONNUMBER
: The version number for the package.
These secrets and variables need to be set in the repository settings under Settings > Secrets and variables.
This workflow is triggered manually via the GitHub Actions interface using the workflow_dispatch
event. To run the workflow:
- Navigate to the Actions tab in your GitHub repository.
- Select the Build and Deploy Package workflow.
- Click the Run workflow button.
This demo project showcases how to integrate github-actions-deploy
for building and deploying a Java Gradle project.