Add GitHub Actions workflow to build and deploy plugin to OMCSI#7
Conversation
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
There was a problem hiding this comment.
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.ymlwithworkflow_dispatchand push triggers, plus job-level branch gating viavars.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.
.github/workflows/deploy.yml
Outdated
| uses: gradle/actions/setup-gradle@v4 | ||
|
|
||
| - name: Build plugin JAR | ||
| run: ./gradlew build |
There was a problem hiding this comment.
./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).
| run: ./gradlew build | |
| run: gradle build |
.github/workflows/deploy.yml
Outdated
| # 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 |
There was a problem hiding this comment.
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).
| # 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) |
| echo "❌ PLUGIN_JAR_NAME variable is not set" | ||
| exit 1 | ||
| fi | ||
|
|
There was a problem hiding this comment.
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.
| 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 address comments |
…date secrets Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Addressed all three review comments in 4e5e033:
|
Adds
.github/workflows/deploy.ymlto 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 build) viagradle/actions/setup-gradle@v4, which makesgradleavailable regardless of whether a Gradle wrapper exists in the repobuild.gradletarget)build/libs/excluding-sources/-javadocJARs, with strict validation that exactly one candidate JAR exists to avoid deploying the wrong artifactvars.DEPLOY_BRANCH(default:main), evaluated at job level sincevars.*isn't available inon:filtersworkflow_dispatchfor manual triggers from the Actions tabPLUGIN_JAR_NAME, missingOMCSI_DEPLOY_URL/OMCSI_DEPLOY_TOKENsecrets, 401 auth failures, 400 bad requests, network errors, and unexpected status codesRequired repo configuration
OMCSI_DEPLOY_URLOMCSI_DEPLOY_TOKENDEPLOY_AUTH_TOKENfrom omcsi.envPLUGIN_JAR_NAMEHerald.jarDEPLOY_BRANCHmain)Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.