mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-04-03 14:06:23 +00:00
286 lines
12 KiB
YAML
286 lines
12 KiB
YAML
name: 'MCP: Container Build and Push'
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
paths:
|
|
- 'mcp_server/**'
|
|
- '.github/workflows/mcp-container-build-push.yml'
|
|
release:
|
|
types:
|
|
- 'published'
|
|
workflow_dispatch:
|
|
inputs:
|
|
release_tag:
|
|
description: 'Release tag (e.g., 5.14.0)'
|
|
required: true
|
|
type: string
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
env:
|
|
# Tags
|
|
LATEST_TAG: latest
|
|
RELEASE_TAG: ${{ github.event.release.tag_name || inputs.release_tag }}
|
|
STABLE_TAG: stable
|
|
WORKING_DIRECTORY: ./mcp_server
|
|
|
|
# Container registries
|
|
PROWLERCLOUD_DOCKERHUB_REPOSITORY: prowlercloud
|
|
PROWLERCLOUD_DOCKERHUB_IMAGE: prowler-mcp
|
|
|
|
jobs:
|
|
setup:
|
|
if: github.repository == 'prowler-cloud/prowler'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
outputs:
|
|
short-sha: ${{ steps.set-short-sha.outputs.short-sha }}
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
|
|
with:
|
|
egress-policy: block
|
|
|
|
- name: Calculate short SHA
|
|
id: set-short-sha
|
|
run: echo "short-sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
|
|
|
|
notify-release-started:
|
|
if: github.repository == 'prowler-cloud/prowler' && (github.event_name == 'release' || github.event_name == 'workflow_dispatch')
|
|
needs: setup
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
outputs:
|
|
message-ts: ${{ steps.slack-notification.outputs.ts }}
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Harden the runner (Audit all outbound calls)
|
|
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Notify container push started
|
|
id: slack-notification
|
|
uses: ./.github/actions/slack-notification
|
|
env:
|
|
SLACK_CHANNEL_ID: ${{ secrets.SLACK_PLATFORM_DEPLOYMENTS }}
|
|
COMPONENT: MCP
|
|
RELEASE_TAG: ${{ env.RELEASE_TAG }}
|
|
GITHUB_SERVER_URL: ${{ github.server_url }}
|
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
|
GITHUB_RUN_ID: ${{ github.run_id }}
|
|
with:
|
|
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
|
|
payload-file-path: "./.github/scripts/slack-messages/container-release-started.json"
|
|
|
|
container-build-push:
|
|
needs: [setup, notify-release-started]
|
|
if: always() && needs.setup.result == 'success' && (needs.notify-release-started.result == 'success' || needs.notify-release-started.result == 'skipped')
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
runner: ubuntu-latest
|
|
arch: amd64
|
|
- platform: linux/arm64
|
|
runner: ubuntu-24.04-arm
|
|
arch: arm64
|
|
timeout-minutes: 30
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
|
|
with:
|
|
egress-policy: block
|
|
allowed-endpoints: >
|
|
github.com:443
|
|
registry-1.docker.io:443
|
|
auth.docker.io:443
|
|
production.cloudflare.docker.com:443
|
|
ghcr.io:443
|
|
pkg-containers.githubusercontent.com:443
|
|
files.pythonhosted.org:443
|
|
pypi.org:443
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
|
|
|
- name: Build and push MCP container for ${{ matrix.arch }}
|
|
id: container-push
|
|
if: github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'workflow_dispatch'
|
|
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
|
|
with:
|
|
context: ${{ env.WORKING_DIRECTORY }}
|
|
push: true
|
|
platforms: ${{ matrix.platform }}
|
|
tags: |
|
|
${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${{ needs.setup.outputs.short-sha }}-${{ matrix.arch }}
|
|
labels: |
|
|
org.opencontainers.image.title=Prowler MCP Server
|
|
org.opencontainers.image.description=Model Context Protocol server for Prowler
|
|
org.opencontainers.image.vendor=ProwlerPro, Inc.
|
|
org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
org.opencontainers.image.created=${{ github.event_name == 'release' && github.event.release.published_at || github.event.head_commit.timestamp }}
|
|
${{ github.event_name == 'release' && format('org.opencontainers.image.version={0}', env.RELEASE_TAG) || '' }}
|
|
cache-from: type=gha,scope=${{ matrix.arch }}
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
|
|
|
|
# Create and push multi-architecture manifest
|
|
create-manifest:
|
|
needs: [setup, container-build-push]
|
|
if: always() && needs.setup.result == 'success' && needs.container-build-push.result == 'success'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
|
|
with:
|
|
egress-policy: block
|
|
allowed-endpoints: >
|
|
registry-1.docker.io:443
|
|
auth.docker.io:443
|
|
production.cloudflare.docker.com:443
|
|
github.com:443
|
|
release-assets.githubusercontent.com:443
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Create and push manifests for push event
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
docker buildx imagetools create \
|
|
-t ${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${{ env.LATEST_TAG }} \
|
|
-t ${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${NEEDS_SETUP_OUTPUTS_SHORT_SHA} \
|
|
${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${NEEDS_SETUP_OUTPUTS_SHORT_SHA}-amd64 \
|
|
${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${NEEDS_SETUP_OUTPUTS_SHORT_SHA}-arm64
|
|
env:
|
|
NEEDS_SETUP_OUTPUTS_SHORT_SHA: ${{ needs.setup.outputs.short-sha }}
|
|
|
|
- name: Create and push manifests for release event
|
|
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
|
|
run: |
|
|
docker buildx imagetools create \
|
|
-t ${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${RELEASE_TAG} \
|
|
-t ${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${{ env.STABLE_TAG }} \
|
|
${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${NEEDS_SETUP_OUTPUTS_SHORT_SHA}-amd64 \
|
|
${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${NEEDS_SETUP_OUTPUTS_SHORT_SHA}-arm64
|
|
env:
|
|
NEEDS_SETUP_OUTPUTS_SHORT_SHA: ${{ needs.setup.outputs.short-sha }}
|
|
|
|
- name: Install regctl
|
|
if: always()
|
|
uses: regclient/actions/regctl-installer@da9319db8e44e8b062b3a147e1dfb2f574d41a03 # main
|
|
|
|
- name: Cleanup intermediate architecture tags
|
|
if: always()
|
|
run: |
|
|
echo "Cleaning up intermediate tags..."
|
|
regctl tag delete "${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${NEEDS_SETUP_OUTPUTS_SHORT_SHA}-amd64" || true
|
|
regctl tag delete "${{ env.PROWLERCLOUD_DOCKERHUB_REPOSITORY }}/${{ env.PROWLERCLOUD_DOCKERHUB_IMAGE }}:${NEEDS_SETUP_OUTPUTS_SHORT_SHA}-arm64" || true
|
|
echo "Cleanup completed"
|
|
env:
|
|
NEEDS_SETUP_OUTPUTS_SHORT_SHA: ${{ needs.setup.outputs.short-sha }}
|
|
|
|
notify-release-completed:
|
|
if: always() && needs.notify-release-started.result == 'success' && (github.event_name == 'release' || github.event_name == 'workflow_dispatch')
|
|
needs: [setup, notify-release-started, container-build-push, create-manifest]
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Harden the runner (Audit all outbound calls)
|
|
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Determine overall outcome
|
|
id: outcome
|
|
run: |
|
|
if [[ "${NEEDS_CONTAINER_BUILD_PUSH_RESULT}" == "success" && "${NEEDS_CREATE_MANIFEST_RESULT}" == "success" ]]; then
|
|
echo "outcome=success" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "outcome=failure" >> $GITHUB_OUTPUT
|
|
fi
|
|
env:
|
|
NEEDS_CONTAINER_BUILD_PUSH_RESULT: ${{ needs.container-build-push.result }}
|
|
NEEDS_CREATE_MANIFEST_RESULT: ${{ needs.create-manifest.result }}
|
|
|
|
- name: Notify container push completed
|
|
uses: ./.github/actions/slack-notification
|
|
env:
|
|
SLACK_CHANNEL_ID: ${{ secrets.SLACK_PLATFORM_DEPLOYMENTS }}
|
|
MESSAGE_TS: ${{ needs.notify-release-started.outputs.message-ts }}
|
|
COMPONENT: MCP
|
|
RELEASE_TAG: ${{ env.RELEASE_TAG }}
|
|
GITHUB_SERVER_URL: ${{ github.server_url }}
|
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
|
GITHUB_RUN_ID: ${{ github.run_id }}
|
|
with:
|
|
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
|
|
payload-file-path: "./.github/scripts/slack-messages/container-release-completed.json"
|
|
step-outcome: ${{ steps.outcome.outputs.outcome }}
|
|
update-ts: ${{ needs.notify-release-started.outputs.message-ts }}
|
|
|
|
trigger-deployment:
|
|
needs: [setup, container-build-push]
|
|
if: always() && github.event_name == 'push' && needs.setup.result == 'success' && needs.container-build-push.result == 'success'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
|
|
with:
|
|
egress-policy: block
|
|
allowed-endpoints: >
|
|
api.github.com:443
|
|
|
|
- name: Trigger MCP deployment
|
|
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
|
|
with:
|
|
token: ${{ secrets.PROWLER_BOT_ACCESS_TOKEN }}
|
|
repository: ${{ secrets.CLOUD_DISPATCH }}
|
|
event-type: mcp-prowler-deployment
|
|
client-payload: '{"sha": "${{ github.sha }}", "short_sha": "${{ needs.setup.outputs.short-sha }}"}'
|