fix: avoid 401 errors during /mcp requests with service account (#37) #181
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "*" | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "**/*.md" | |
| permissions: {} | |
| jobs: | |
| lint: | |
| name: Lint Code | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| show-progress: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
| with: | |
| node-version-file: .nvmrc | |
| check-latest: true | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Run Linter | |
| run: npm run lint | |
| test: | |
| name: Testing on ${{ matrix.os }} | |
| needs: | |
| - lint | |
| strategy: | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| show-progress: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
| with: | |
| node-version-file: .nvmrc | |
| check-latest: true | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Run Tests | |
| run: npm run coverage | |
| release: | |
| name: Build Docker Image and Release | |
| needs: | |
| - test | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: write | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| show-progress: false | |
| - name: Docker Login to GitHub Repository | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker Login to DockerHub | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| username: ${{ secrets.BOT_DOCKER_USERNAME }} | |
| password: ${{ secrets.BOT_DOCKER_TOKEN }} | |
| - name: Docker Login to Mia registry | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 | |
| with: | |
| registry: nexus.mia-platform.eu | |
| username: ${{ secrets.NEXUS_USER }} | |
| password: ${{ secrets.NEXUS_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 | |
| with: | |
| platforms: amd64,arm64 | |
| - name: Configure Docker Metadata | |
| id: meta | |
| uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 | |
| env: | |
| DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | |
| with: | |
| images: | | |
| ghcr.io/mia-platform/console-mcp-server | |
| docker.io/miaplatform/console-mcp-server | |
| nexus.mia-platform.eu/console/mcp-server | |
| tags: | | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| labels: | | |
| org.opencontainers.image.authors=Mia Platform Core Team<[email protected]> | |
| org.opencontainers.image.documentation=https://docs.mia-platform.eu/docs/marketplace/handbooks/crud-oss-usage | |
| org.opencontainers.image.vendor=Mia s.r.l. | |
| annotations: | | |
| org.opencontainers.image.authors=Mia Platform Core Team<[email protected]> | |
| org.opencontainers.image.documentation=https://docs.mia-platform.eu/docs/marketplace/handbooks/crud-oss-usage | |
| org.opencontainers.image.vendor=Mia s.r.l. | |
| - name: Setup Buildx Context | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 | |
| id: buildx | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| - name: Build and Push | |
| id: docker-build | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| annotations: ${{ steps.meta.outputs.annotations }} | |
| platforms: ${{ steps.buildx.outputs.platforms }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Install Cosign | |
| uses: sigstore/cosign-installer@d7543c93d881b35a8faa02e8e3605f69b7a1ce62 # v3.10.0 | |
| if: github.ref_type == 'tag' | |
| - name: GCP Auth | |
| uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0 | |
| if: github.ref_type == 'tag' | |
| with: | |
| project_id: ${{ secrets.MIA_PLATFORM_KMS_GCP_PROJECT }} | |
| workload_identity_provider: ${{ secrets.MIA_PLATFORM_WIF }} | |
| create_credentials_file: true | |
| - name: Generate SBOM | |
| uses: anchore/sbom-action@f8bdd1d8ac5e901a77a92f111440fdb1b593736b # v0.20.6 | |
| if: github.ref_type == 'tag' | |
| with: | |
| artifact-name: mcp-server-sbom.spdx.json | |
| output-file: ./mcp-server-sbom.spdx.json | |
| image: nexus.mia-platform.eu/console/mcp-server:${{ steps.meta.outputs.version }} | |
| upload-release-assets: true | |
| - name: Sign image with a key | |
| if: github.ref_type == 'tag' | |
| run: | | |
| images="" | |
| for tag in ${TAGS}; do | |
| images+="${tag}@${DIGEST} " | |
| done | |
| cosign sign --recursive --yes --key "${COSIGN_PRIVATE_KEY}" ${images} | |
| cosign attest --yes --key "${COSIGN_PRIVATE_KEY}" --predicate "mcp-server-sbom.spdx.json" --type="spdxjson" ${images} | |
| env: | |
| TAGS: | | |
| ghcr.io/mia-platform/console-mcp-server:${{ steps.meta.outputs.version }} | |
| docker.io/miaplatform/console-mcp-server:${{ steps.meta.outputs.version }} | |
| nexus.mia-platform.eu/console/mcp-server:${{ steps.meta.outputs.version }} | |
| COSIGN_PRIVATE_KEY: ${{ secrets.MIA_PLATFORM_KEY_KMS }} | |
| DIGEST: ${{ steps.docker-build.outputs.digest }} | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | |
| with: | |
| node-version: 24 | |
| check-latest: true | |
| registry-url: https://registry.npmjs.org/ | |
| - run: npm ci | |
| - run: npm run build | |
| - run: npm publish --access=public |