Skip to content

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

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-github-actions-workflow
Draft

Add GitHub Actions workflow to build and deploy plugin to OMCSI#85
Copilot wants to merge 3 commits intomainfrom
copilot/add-github-actions-workflow

Conversation

Copy link
Contributor

Copilot AI commented Mar 8, 2026

  • Create .github/workflows/deploy.yml modeled after the Activity Tracker reference workflow
  • Verify the workflow file is valid YAML and matches all acceptance criteria
  • Address review feedback: enable Maven dependency caching (cache: maven)
  • Address review feedback: validate DEPLOY_URL and DEPLOY_TOKEN before curl
  • Address review feedback: add --show-error to curl for better diagnostics
  • Run code review
  • Run CodeQL security check
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)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

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 8, 2026
@dmccoystephenson dmccoystephenson requested a review from Copilot March 8, 2026 18:38
Copy link

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 CI/CD workflow that builds the plugin with Maven and deploys the resulting JAR to an OMCSI instance via an authenticated HTTP POST.

Changes:

  • Introduces .github/workflows/deploy.yml with push + workflow_dispatch triggers and branch-gated deploy logic.
  • Builds with Temurin JDK 8 and packages via mvn --batch-mode package, then locates the shaded JAR from target/.
  • Deploys to OMCSI_DEPLOY_URL/api/plugins/deploy using bearer auth and handles common HTTP failure statuses.

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

uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '8'
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

Consider enabling Maven dependency caching in setup-java (e.g., cache: maven). Without it, each run downloads dependencies from scratch, which can significantly slow down CI and increase the chance of transient network failures during builds.

Suggested change
java-version: '8'
java-version: '8'
cache: maven

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +93
HTTP_STATUS=$(curl --silent --write-out "%{http_code}" \
--output "${RESPONSE_BODY}" \
--request POST \
--header "Authorization: Bearer ${DEPLOY_TOKEN}" \
--form "pluginName=${PLUGIN_JAR_NAME}" \
--form "file=@${JAR_FILE}" \
--form "branch=${{ github.ref_name }}" \
--form "repoUrl=${{ github.server_url }}/${{ github.repository }}" \
"${DEPLOY_URL}/api/plugins/deploy") || {
echo "❌ curl failed – network error or invalid URL"
exit 1
}
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

curl is run with --silent, which suppresses useful diagnostics (DNS/TLS issues, connection refusals) unless you explicitly print them. Adding --show-error (and optionally --location if the endpoint may redirect) would make failures easier to debug while keeping output mostly clean.

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

Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

The deploy step validates PLUGIN_JAR_NAME but doesn’t validate that OMCSI_DEPLOY_URL / OMCSI_DEPLOY_TOKEN are actually set. If either secret is missing/empty, the workflow will fail later with a generic curl/network/URL error, which doesn’t meet the “missing variables/secrets produce a clear error message” goal. Add explicit checks for DEPLOY_URL and DEPLOY_TOKEN and fail with targeted messages before invoking curl.

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
Member

@copilot address comments

…o curl

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

Copilot AI commented Mar 8, 2026

@copilot address comments

All three review comments addressed in e3cc9d8:

  • Added cache: maven to setup-java for dependency caching
  • Added explicit validation of DEPLOY_URL and DEPLOY_TOKEN with clear error messages before the curl call
  • Added --show-error to curl so DNS/TLS/connection errors are surfaced

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