From 2a33f78adc2d3c88d048f8311cf35f18498e13d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:55:52 +0000 Subject: [PATCH 1/3] Initial plan From 66c44517170a53e40799a9448fd68c56caadfd5a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 17:58:00 +0000 Subject: [PATCH 2/3] Add GitHub Actions workflow to build and deploy plugin to OMCSI Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com> --- .github/workflows/deploy.yml | 109 +++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..0faaf09 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,109 @@ +# Workflow to automatically build the Mailboxes plugin JAR and deploy it +# to a running omcsi (open-mc-server-infrastructure) instance. +# +# ─── Setup ─────────────────────────────────────────────────────────────────── +# Required GitHub repository secrets: +# OMCSI_DEPLOY_URL – Base URL of your omcsi instance, +# e.g. https://mc.example.com:8092 +# OMCSI_DEPLOY_TOKEN – The value set as DEPLOY_AUTH_TOKEN in your omcsi .env +# +# Required GitHub repository variables: +# PLUGIN_JAR_NAME – Filename of the plugin JAR on the server, +# e.g. Mailboxes.jar (the file that will be replaced) +# +# Optional GitHub repository variables: +# DEPLOY_BRANCH – Branch that triggers a deployment (default: main) +# ───────────────────────────────────────────────────────────────────────────── + +name: Deploy Plugin to omcsi + +# Trigger on pushes (branch-gated via the job condition) and on manual runs +# via the "Run workflow" button in the Actions tab. +# Note: ${{ vars.* }} expressions are NOT evaluated inside the `on:` event +# filter – only inside job steps and conditions. +on: + push: + workflow_dispatch: + +jobs: + build-and-deploy: + name: Build and Deploy Plugin + # Run on manual dispatch (any branch) or when the pushed branch matches + # DEPLOY_BRANCH (default: main). + if: ${{ github.event_name == 'workflow_dispatch' || github.ref_name == (vars.DEPLOY_BRANCH || 'main') }} + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '8' + + - name: Build plugin JAR + run: mvn --batch-mode package + + - name: Locate built JAR + id: locate-jar + run: | + # Use find to reliably locate the shaded JAR, excluding the maven-shade-plugin's + # original (pre-shading) copy and any *-sources / *-javadoc JARs. + JAR_FILE=$(find target -maxdepth 1 -name '*.jar' \ + ! -name 'original-*' \ + ! -name '*-sources.jar' \ + ! -name '*-javadoc.jar' \ + -print -quit) + if [ -z "${JAR_FILE}" ]; then + echo "❌ No JAR found in target/" + exit 1 + fi + echo "jar_file=${JAR_FILE}" >> "$GITHUB_OUTPUT" + echo "✅ Found JAR: ${JAR_FILE}" + + - name: Deploy plugin to omcsi + env: + DEPLOY_TOKEN: ${{ secrets.OMCSI_DEPLOY_TOKEN }} + DEPLOY_URL: ${{ secrets.OMCSI_DEPLOY_URL }} + JAR_FILE: ${{ steps.locate-jar.outputs.jar_file }} + run: | + PLUGIN_JAR_NAME="${{ vars.PLUGIN_JAR_NAME }}" + if [ -z "${PLUGIN_JAR_NAME}" ]; then + echo "❌ PLUGIN_JAR_NAME variable is not set" + exit 1 + fi + + RESPONSE_BODY=$(mktemp) + trap 'rm -f "${RESPONSE_BODY}"' EXIT + 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 + } + + if [ "${HTTP_STATUS}" -eq 200 ]; then + echo "✅ Plugin deployed successfully (HTTP ${HTTP_STATUS})" + elif [ "${HTTP_STATUS}" -eq 401 ]; then + echo "❌ Authentication failed – check OMCSI_DEPLOY_TOKEN (HTTP ${HTTP_STATUS})" + echo "Response body:"; cat "${RESPONSE_BODY}" + exit 1 + elif [ "${HTTP_STATUS}" -eq 400 ]; then + echo "❌ Bad request – check PLUGIN_JAR_NAME and the uploaded JAR (HTTP ${HTTP_STATUS})" + echo "Response body:"; cat "${RESPONSE_BODY}" + exit 1 + else + echo "❌ Deployment failed (HTTP ${HTTP_STATUS})" + echo "Response body:"; cat "${RESPONSE_BODY}" + exit 1 + fi From e3cc9d8d613aace3fc43326e5d3286c050a487e5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 18:45:09 +0000 Subject: [PATCH 3/3] Address review: add Maven cache, validate secrets, add --show-error to curl Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com> --- .github/workflows/deploy.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0faaf09..11e76d9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -44,6 +44,7 @@ jobs: with: distribution: temurin java-version: '8' + cache: maven - name: Build plugin JAR run: mvn --batch-mode package @@ -77,9 +78,19 @@ jobs: exit 1 fi + 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 + RESPONSE_BODY=$(mktemp) trap 'rm -f "${RESPONSE_BODY}"' EXIT - HTTP_STATUS=$(curl --silent --write-out "%{http_code}" \ + HTTP_STATUS=$(curl --silent --show-error --write-out "%{http_code}" \ --output "${RESPONSE_BODY}" \ --request POST \ --header "Authorization: Bearer ${DEPLOY_TOKEN}" \