Illumio MCP Server
by alexgoller
- .github
- workflows
name: Build and Publish Docker Image
on:
release:
types: [published]
push:
branches: [ "main" ] # or "master" depending on your default branch
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
issues: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# For releases
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'release' }}
# For pushes to main
type=sha,prefix=sha-,enable=${{ github.event_name == 'push' }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
provenance: false
- name: Update release with image details
uses: softprops/action-gh-release@v1
if: github.event_name == 'release'
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Docker image available at:
```
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
```
Pull with:
```bash
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
```
- name: Comment PR with image details
if: github.event_name == 'push'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const sha = context.sha.substring(0, 7);
const message = `
🐳 Docker image built and pushed:
\`\`\`
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${sha}
\`\`\`
`;
try {
await github.rest.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha,
body: message
});
} catch (error) {
console.log('Failed to create commit comment:', error);
// Create an issue instead as fallback
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Docker image built for commit ${sha}`,
body: message
});
}