Add MCP registry details #1
Workflow file for this run
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 Container | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| image_name: | ||
| required: true | ||
| type: string | ||
| force: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| env: | ||
| REGISTRY: ghcr.io | ||
| REPOSITORY: ${{ github.repository }} | ||
| jobs: | ||
| build-and-push-image: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| packages: write | ||
| attestations: write | ||
| id-token: write | ||
| env: | ||
| BUILD_IMAGE: true | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Set up .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: '10.x' | ||
| - name: Pull the latest metadata.json | ||
| if: inputs.image_name == 'awesome-copilot' | ||
| shell: bash | ||
| run: | | ||
| git pull origin main | ||
| - name: Checkout repository - Awesome Copilot | ||
| if: inputs.image_name == 'awesome-copilot' | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: github/awesome-copilot | ||
| path: awesome-copilot/src/awesome-copilot | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Update metadata.json | ||
| if: inputs.image_name == 'awesome-copilot' | ||
| shell: bash | ||
| run: | | ||
| pushd awesome-copilot | ||
| dotnet run ./update-metadata.cs | ||
| popd | ||
| - name: Push metadata.json | ||
| if: inputs.image_name == 'awesome-copilot' | ||
| shell: bash | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| git config --global user.name "GitHub Actions" | ||
| git config --global user.email "actions@github.com" | ||
| git add awesome-copilot/src/McpSamples.AwesomeCopilot.HybridApp/metadata.json | ||
| if git diff --staged --quiet; then | ||
| echo "No changes to commit" | ||
| echo "BUILD_IMAGE=false" >> $GITHUB_ENV | ||
| else | ||
| git commit -m "Update metadata.json" | ||
| git push origin main | ||
| fi | ||
| - name: Get registry version | ||
| if: inputs.image_name == 'awesome-copilot' | ||
| id: registry | ||
| shell: pwsh | ||
| run: | | ||
| pushd awesome-copilot | ||
| $server = Get-Content ./server.json | ConvertFrom-Json | ||
| $version = $($server.version).Split(".") | ||
| $release = Get-Date -Format "yyyyMMddHH" -AsUTC | ||
| $revised = "$([string]::Join(".", $version[0..1])).$release" | ||
| $server.version = $revised | ||
| $server.packages[0].version = $revised | ||
| $server | ConvertTo-Json -Depth 10 | Out-File -FilePath ./server.json -Encoding utf8 -Force | ||
| echo "version=$revised" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | ||
| popd | ||
| - name: Build app | ||
| if: env.BUILD_IMAGE == 'true' || inputs.force == true | ||
| shell: bash | ||
| run: | | ||
| pushd ${{ inputs.image_name }} | ||
| dotnet restore && dotnet build | ||
| popd | ||
| - name: Check if Dockerfile exists | ||
| if: env.BUILD_IMAGE == 'true' || inputs.force == true | ||
| id: check-dockerfile | ||
| shell: bash | ||
| run: | | ||
| if [ -f "${{ github.workspace }}/Dockerfile.${{ inputs.image_name }}" ]; then | ||
| echo "exists=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "exists=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| - name: Log in to the Container registry | ||
| if: | | ||
| (env.BUILD_IMAGE == 'true' || inputs.force == true) && | ||
| steps.check-dockerfile.outputs.exists == 'true' | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Extract metadata (tags, labels) for Docker | ||
| if: | | ||
| (env.BUILD_IMAGE == 'true' || inputs.force == true) && | ||
| steps.check-dockerfile.outputs.exists == 'true' | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }} | ||
| - name: Set up Docker Buildx | ||
| if: | | ||
| (env.BUILD_IMAGE == 'true' || inputs.force == true) && | ||
| steps.check-dockerfile.outputs.exists == 'true' | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Build and push Docker image - multi-platform for awesome-copilot | ||
| if: | | ||
| (env.BUILD_IMAGE == 'true' || inputs.force == true) && | ||
| steps.check-dockerfile.outputs.exists == 'true' && | ||
| inputs.image_name == 'awesome-copilot' | ||
| id: push-multiplatform | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| platforms: linux/amd64,linux/arm64 | ||
| push: true | ||
| context: ${{ github.workspace }} | ||
| file: ${{ github.workspace }}/Dockerfile.${{ inputs.image_name }} | ||
| tags: '${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }}:latest,${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }}:${{ steps.registry.outputs.version }}' | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| - name: Build and push Docker image - multi-platform for other images | ||
| if: | | ||
| (env.BUILD_IMAGE == 'true' || inputs.force == true) && | ||
| steps.check-dockerfile.outputs.exists == 'true' && | ||
| inputs.image_name != 'awesome-copilot' | ||
| id: push-multiplatform | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| platforms: linux/amd64,linux/arm64 | ||
| push: true | ||
| context: ${{ github.workspace }} | ||
| file: ${{ github.workspace }}/Dockerfile.${{ inputs.image_name }} | ||
| tags: '${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }}:latest' | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| - name: Generate artifact attestation - multi-platform | ||
| if: | | ||
| (env.BUILD_IMAGE == 'true' || inputs.force == true) && | ||
| steps.check-dockerfile.outputs.exists == 'true' | ||
| uses: actions/attest-build-provenance@v2 | ||
| with: | ||
| subject-name: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ inputs.image_name }} | ||
| subject-digest: ${{ steps.push-multiplatform.outputs.digest }} | ||
| push-to-registry: true | ||
| - name: Install mcp-publisher | ||
| if: inputs.image_name == 'awesome-copilot' | ||
| shell: bash | ||
| 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 | ||
| - name: Authenticate to MCP Registry | ||
| if: inputs.image_name == 'awesome-copilot' | ||
| shell: bash | ||
| run: | | ||
| ./mcp-publisher login github-oidc | ||
| - name: Publish server to MCP Registry | ||
| if: inputs.image_name == 'awesome-copilot' | ||
| shell: bash | ||
| run: | | ||
| ./mcp-publisher publish | ||