Skip to content

Add GitHub Actions workflow to build and deploy plugin to OMCSI#7

Merged
dmccoystephenson merged 8 commits intodevfrom
copilot/add-github-actions-workflow
Mar 7, 2026
Merged

Add GitHub Actions workflow to build and deploy plugin to OMCSI#7
dmccoystephenson merged 8 commits intodevfrom
copilot/add-github-actions-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 7, 2026

Adds .github/workflows/deploy.yml to automatically build the Herald plugin JAR and deploy it to an omcsi instance.

Modeled after the Activity Tracker deploy workflow, adapted for this project's toolchain:

  • Gradle (gradle build) via gradle/actions/setup-gradle@v4, which makes gradle available regardless of whether a Gradle wrapper exists in the repo
  • JDK 21 (matching build.gradle target)
  • JAR discovery in build/libs/ excluding -sources/-javadoc JARs, with strict validation that exactly one candidate JAR exists to avoid deploying the wrong artifact
  • Branch gating via vars.DEPLOY_BRANCH (default: main), evaluated at job level since vars.* isn't available in on: filters
  • workflow_dispatch for manual triggers from the Actions tab
  • Error handling with distinct messages for missing PLUGIN_JAR_NAME, missing OMCSI_DEPLOY_URL/OMCSI_DEPLOY_TOKEN secrets, 401 auth failures, 400 bad requests, network errors, and unexpected status codes

Required repo configuration

Secrets
OMCSI_DEPLOY_URL Base URL of the omcsi instance
OMCSI_DEPLOY_TOKEN DEPLOY_AUTH_TOKEN from omcsi .env
Variables
PLUGIN_JAR_NAME Target filename on server, e.g. Herald.jar
DEPLOY_BRANCH Branch that triggers deploys (default: main)
Original prompt

This section details on the original issue you should resolve

<issue_title>Add GitHub Actions workflow to build and deploy plugin to OMCSI</issue_title>
<issue_description>## Summary

Add a .github/workflows/deploy.yml file that automatically builds the plugin JAR and deploys it to the omcsi (open-mc-server-infrastructure) instance when changes are pushed to the deploy branch.

Implementation

Create .github/workflows/deploy.yml modeled after the Activity Tracker reference workflow with the following adjustments for this project:

  • JDK version: [8 / 11 / 17 / 21]
  • Build tool & command:
    • Maven: mvn --batch-mode package
    • Gradle: ./gradlew build
  • JAR location:
    • Maven: target/ (exclude original-*, *-sources.jar, *-javadoc.jar)
    • Gradle: build/libs/ (exclude *-sources.jar, *-javadoc.jar)

Required Secrets

Add via repo Settings → Secrets and variables → Actions:

Secret Value
OMCSI_DEPLOY_URL Base URL of the omcsi instance, e.g. https://mc.example.com:8092
OMCSI_DEPLOY_TOKEN Value of DEPLOY_AUTH_TOKEN from the omcsi .env file

Required Variables

Add via repo Settings → Secrets and variables → Actions → Variables:

Variable Value
PLUGIN_JAR_NAME Filename of the JAR on the server, e.g. MyPlugin.jar
DEPLOY_BRANCH Branch that triggers deploys (default: main)

Acceptance Criteria

  • .github/workflows/deploy.yml exists in the repo
  • Pushing to the deploy branch triggers a build and successful deploy
  • Workflow can also be triggered manually via the Actions tab (workflow_dispatch)
  • Failed builds, missing variables, auth errors, and bad requests all produce a clear error message and non-zero exit code
  • Secrets and variables documented in this ticket are configured in the repo

Reference

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copilot AI changed the title [WIP] Add GitHub Actions workflow to build and deploy plugin Add GitHub Actions workflow to build and deploy plugin to OMCSI Mar 7, 2026
@dmccoystephenson dmccoystephenson requested a review from Copilot March 7, 2026 03:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a GitHub Actions deployment workflow intended to build the Herald plugin JAR and deploy it to an OMCSI instance on push (branch-gated) or manual trigger.

Changes:

  • Introduces .github/workflows/deploy.yml with workflow_dispatch and push triggers, plus job-level branch gating via vars.DEPLOY_BRANCH.
  • Builds the plugin via Gradle, locates a JAR in build/libs/, and POSTs it to the OMCSI deploy endpoint with basic HTTP-status-based error handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

uses: gradle/actions/setup-gradle@v4

- name: Build plugin JAR
run: ./gradlew build
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./gradlew build will fail in this repo as-is because there is no Gradle wrapper script (gradlew) or Gradle build files checked in. Either commit the Gradle wrapper + build configuration, or switch this step to use the actual build command/tooling present in the repository (e.g., gradle build if you intentionally rely on setup-gradle).

Suggested change
run: ./gradlew build
run: gradle build

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +66
# Use find to reliably locate the built JAR, excluding any
# *-sources / *-javadoc JARs.
JAR_FILE=$(find build/libs -maxdepth 1 -name '*.jar' \
! -name '*-sources.jar' \
! -name '*-javadoc.jar' \
-print -quit)
if [ -z "${JAR_FILE}" ]; then
echo "❌ No JAR found in build/libs/"
exit 1
fi
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JAR selection uses find ... -print -quit, which will pick the first matching JAR in directory order. If multiple non-sources/non-javadoc JARs are produced (e.g., shaded + plain, or multiple variants), this can deploy the wrong artifact. Consider failing if there is not exactly one candidate, or selecting deterministically (e.g., by expected filename/pattern).

Suggested change
# Use find to reliably locate the built JAR, excluding any
# *-sources / *-javadoc JARs.
JAR_FILE=$(find build/libs -maxdepth 1 -name '*.jar' \
! -name '*-sources.jar' \
! -name '*-javadoc.jar' \
-print -quit)
if [ -z "${JAR_FILE}" ]; then
echo "❌ No JAR found in build/libs/"
exit 1
fi
# Locate candidate JARs, excluding *-sources / *-javadoc JARs,
# and ensure there is exactly one to avoid deploying the wrong artifact.
JAR_FILES=$(find build/libs -maxdepth 1 -type f -name '*.jar' \
! -name '*-sources.jar' \
! -name '*-javadoc.jar' | sort)
if [ -z "${JAR_FILES}" ]; then
echo "❌ No JAR found in build/libs/"
exit 1
fi
JAR_COUNT=$(printf '%s\n' "${JAR_FILES}" | wc -l | tr -d '[:space:]')
if [ "${JAR_COUNT}" -ne 1 ]; then
echo "❌ Expected exactly one deployable JAR in build/libs/, but found ${JAR_COUNT}:"
printf '%s\n' "${JAR_FILES}"
exit 1
fi
JAR_FILE=$(printf '%s\n' "${JAR_FILES}" | head -n 1)

Copilot uses AI. Check for mistakes.
echo "❌ PLUGIN_JAR_NAME variable is not set"
exit 1
fi

Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step only validates PLUGIN_JAR_NAME; it does not fail fast with a clear message when required secrets are missing/empty (OMCSI_DEPLOY_URL, OMCSI_DEPLOY_TOKEN). Add explicit checks for DEPLOY_URL/DEPLOY_TOKEN before invoking curl so misconfiguration produces the intended distinct error output.

Suggested change
if [ -z "${DEPLOY_URL}" ]; then
echo "❌ OMCSI_DEPLOY_URL secret is not set or is empty"
exit 1
fi
if [ -z "${DEPLOY_TOKEN}" ]; then
echo "❌ OMCSI_DEPLOY_TOKEN secret is not set or is empty"
exit 1
fi

Copilot uses AI. Check for mistakes.
@dmccoystephenson
Copy link
Copy Markdown
Member

@copilot address comments

…date secrets

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 7, 2026

@copilot address comments

Addressed all three review comments in 4e5e033:

  • Changed ./gradlew buildgradle build (works with setup-gradle@v4 regardless of wrapper presence)
  • JAR selection now uses grep -c . for robust counting and fails if multiple candidate JARs exist
  • Added fail-fast validation for OMCSI_DEPLOY_URL and OMCSI_DEPLOY_TOKEN secrets before invoking curl

@dmccoystephenson dmccoystephenson changed the base branch from main to dev March 7, 2026 04:24
@dmccoystephenson dmccoystephenson merged commit 7129fc7 into dev Mar 7, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GitHub Actions workflow to build and deploy plugin to OMCSI

3 participants