Skip to content

Build Docker Image

Build Docker Image #34

Workflow file for this run

name: Build Docker Image
on:
release:
types: [published]
pull_request:
paths:
- .dockerignore
- .github/workflows/dockerimage.yml
- Dockerfile
- pyproject.toml
schedule:
- cron: '0 23 * * SUN'
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true
env:
DOCKER_HUB_BASE_NAME: optuna/optuna-mcp
jobs:
dockerimage:
runs-on: ubuntu-latest
# This action cannot be executed in the forked repository.
if: github.repository == 'optuna/optuna-mcp'
steps:
- uses: actions/checkout@v4
- name: Set ENV
run: |
export TAG_NAME="ci"
if [ "${{ github.event_name }}" = 'release' ]; then
export TAG_NAME="${{ github.event.release.tag_name }}"
fi
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
- name: Login to Docker Hub
if: ${{ github.event_name == 'release' || github.event_name == 'schedule' }}
uses: docker/login-action@v3
with:
username: optunabot
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push (Release)
if: ${{ github.event_name == 'release' }}
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.DOCKER_HUB_BASE_NAME }}:${{ env.TAG_NAME }}
${{ env.DOCKER_HUB_BASE_NAME }}:latest
- name: Build and push (Schedule)
if: ${{ github.event_name == 'schedule' }}
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.DOCKER_HUB_BASE_NAME }}:latest
- name: Build only (Pull Request)
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: false