Skip to content

Sync from npm and Publish #11

Sync from npm and Publish

Sync from npm and Publish #11

Workflow file for this run

name: Sync from npm and Publish
on:
schedule:
- cron: "0 * * * *" # hourly
workflow_dispatch:
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
- name: Get latest npm version
id: npm
run: |
NPM_VERSION=$(npm view @black-duck/mcp-server version)
echo "version=$NPM_VERSION" >> "$GITHUB_OUTPUT"
- name: Get current server.json version
id: current
run: |
CURRENT=$(jq -r '.version' server.json)
echo "version=$CURRENT" >> "$GITHUB_OUTPUT"
- name: Check if update needed
id: check
run: |
if [ "${{ steps.npm.outputs.version }}" = "${{ steps.current.outputs.version }}" ]; then
echo "needs_update=false" >> "$GITHUB_OUTPUT"
echo "Already at latest version ${{ steps.current.outputs.version }}, nothing to do." >> "$GITHUB_STEP_SUMMARY"
else
echo "needs_update=true" >> "$GITHUB_OUTPUT"
echo "Update needed: ${{ steps.current.outputs.version }} -> ${{ steps.npm.outputs.version }}" >> "$GITHUB_STEP_SUMMARY"
fi
- name: Update server.json with new version
if: steps.check.outputs.needs_update == 'true'
run: |
VERSION="${{ steps.npm.outputs.version }}"
jq --arg v "$VERSION" '.version = $v | .packages[0].version = $v' server.json > server.tmp
mv server.tmp server.json
- name: Sync README from npm
if: steps.check.outputs.needs_update == 'true'
run: npm view @black-duck/mcp-server readme > README.md
- name: Install mcp-publisher
if: steps.check.outputs.needs_update == 'true'
run: |
curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher
chmod +x mcp-publisher
- name: Validate server.json
if: steps.check.outputs.needs_update == 'true'
run: ./mcp-publisher validate server.json
- name: Authenticate to MCP Registry (DNS)
if: steps.check.outputs.needs_update == 'true'
run: ./mcp-publisher login dns --domain blackduck.com --private-key "${{ secrets.MCP_PRIVATE_KEY }}"
- name: Publish to MCP Registry
if: steps.check.outputs.needs_update == 'true'
run: ./mcp-publisher publish server.json
- name: Commit and push updates
if: steps.check.outputs.needs_update == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add server.json README.md
git commit -m "chore: sync to @black-duck/mcp-server@${{ steps.npm.outputs.version }}"
git push
echo "Published @black-duck/mcp-server@${{ steps.npm.outputs.version }} to MCP Registry" >> "$GITHUB_STEP_SUMMARY"