-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (65 loc) · 3.04 KB
/
Copy pathsync-from-npm.yml
File metadata and controls
79 lines (65 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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"