Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@
### Overview
This workflow builds a Docker image and pushes it to GitHub Container Registry (ghcr.io).

### Trigger
The workflow is manually triggered via `workflow_dispatch`.
### Triggers

### Usage
The workflow is triggered in two ways:

1. **Automatically**: When a pull request is merged to the `main` branch
- The image is automatically built and tagged as `latest`
- Also includes a SHA-based tag with branch prefix

2. **Manually**: Via `workflow_dispatch` in the GitHub Actions UI
- Allows specifying a custom tag
- Default tag is `latest` if not specified

### Manual Usage

1. Go to the "Actions" tab in the GitHub repository
2. Select "Build and Push Docker Image" from the workflows list
Expand All @@ -17,7 +26,7 @@ The workflow is manually triggered via `workflow_dispatch`.
5. Click "Run workflow" to start the build

### Parameters
- **tag**: Docker image tag (e.g., `v1.0.0`, `latest`, `dev`). Default: `latest`
- **tag**: Docker image tag (e.g., `v1.0.0`, `latest`, `dev`). Default: `latest` (only for manual triggers)

### Features
- Multi-platform builds (linux/amd64, linux/arm64)
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
required: false
default: 'latest'
type: string
pull_request:
types:
- closed
branches:
- main

env:
REGISTRY: ghcr.io
Expand All @@ -16,6 +21,8 @@ env:
jobs:
build-and-push:
runs-on: ubuntu-latest
# Only run on workflow_dispatch OR when a PR is merged (not just closed)
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
permissions:
contents: read
packages: write
Expand All @@ -42,7 +49,11 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ inputs.tag }}
# For workflow_dispatch: use the input tag or default to 'latest'
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
# For merged PRs: always tag as 'latest'
type=raw,value=latest,enable=${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
# For all events: add SHA-based tag with branch prefix
type=sha,prefix={{branch}}-

- name: Build and push Docker image
Expand Down