Skip to content
Closed
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
16 changes: 16 additions & 0 deletions .github/workflows/major-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Update Major Version Tag

on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
update-majorver:
name: Update Major Version Tag
runs-on: ubuntu-latest
steps:
- uses: nowactions/update-majorver@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
70 changes: 70 additions & 0 deletions .github/workflows/reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Reusable Docker Build and Push

on:
workflow_call:
inputs:
image-name:
description: 'Name of the Docker image (without prefix)'
required: true
type: string
image-prefix:
description: 'Prefix to add to the image name'
required: false
type: string
default: ''
context:
description: 'Build context path'
required: false
type: string
default: '.'
dockerfile:
description: 'Path to Dockerfile'
required: false
type: string
default: './Dockerfile'
platforms:
description: 'Target platforms for build'
required: false
type: string
default: 'linux/amd64,linux/arm64'
registry:
description: 'Container registry to push to'
required: false
type: string
default: 'ghcr.io'
push:
description: 'Push the image to registry'
required: false
type: boolean
default: true
outputs:
image:
description: 'Full image name with tags'
value: ${{ jobs.docker-build.outputs.image }}
digest:
description: 'Image digest'
value: ${{ jobs.docker-build.outputs.digest }}

jobs:
docker-build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
outputs:
image: ${{ steps.docker-action.outputs.image }}
digest: ${{ steps.docker-action.outputs.digest }}
steps:
- name: Build and Push Docker Image
id: docker-action
uses: RevoTale/docker-release-action@v1
with:
registry: ${{ inputs.registry }}
image-name: ${{ inputs.image-name }}
image-prefix: ${{ inputs.image-prefix }}
context: ${{ inputs.context }}
dockerfile: ${{ inputs.dockerfile }}
platforms: ${{ inputs.platforms }}
push: ${{ inputs.push }}
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test Action

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

jobs:
test-action:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test action (build only)
uses: ./
with:
image-name: test-app
image-prefix: test-
push: false
context: .
dockerfile: ./test/Dockerfile

test-with-prefix:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test action with prefix (build only)
uses: ./
with:
image-name: my-app
image-prefix: myorg-
push: false
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Temporary files
*.tmp
*.temp
/tmp/

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Editor files
.vscode/
.idea/
*.swp
*.swo
*~

# Logs
*.log
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM alpine:latest
WORKDIR /app
CMD ["echo", "Hello from Docker Release Action!"]
166 changes: 164 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,164 @@
# docker-release-action
A GitHub CI action to deploy multi-platform docker image.
# Docker Release Action

A GitHub CI Action to deploy multi-platform Docker images with configurable prefixes and reusable workflows.

## Features

- 🐳 **Multi-platform builds** - Supports linux/amd64 and linux/arm64 by default
- 🏷️ **Configurable image prefixes** - Add custom prefixes to your image names
- 🔄 **Reusable workflows** - Easily integrate into any repository
- 🔐 **Flexible registry support** - Works with GitHub Container Registry, Docker Hub, and others
- ⚡ **Composite action** - Fast execution with minimal overhead

## Usage

### Basic Usage

```yaml
name: Build and Push Docker Image
on:
release:
types: [published]

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: RevoTale/docker-release-action@v1
with:
image-name: my-app
```

### Advanced Usage with Prefix

```yaml
name: Build and Push Docker Image
on:
release:
types: [published]

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: RevoTale/docker-release-action@v1
with:
registry: ghcr.io
image-name: my-app
image-prefix: my-org-
context: ./docker
dockerfile: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
```

### Multiple Images with Different Prefixes

```yaml
name: Build Multiple Images
on:
release:
types: [published]

jobs:
build-api:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: RevoTale/docker-release-action@v1
with:
image-name: api
image-prefix: myproject-
context: ./api
dockerfile: ./api/Dockerfile

build-frontend:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: RevoTale/docker-release-action@v1
with:
image-name: frontend
image-prefix: myproject-
context: ./frontend
dockerfile: ./frontend/Dockerfile
```

## Inputs

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `registry` | Container registry to push to | No | `ghcr.io` |
| `image-name` | Name of the Docker image (without prefix) | Yes | - |
| `image-prefix` | Prefix to add to the image name | No | `""` |
| `context` | Build context path | No | `.` |
| `dockerfile` | Path to Dockerfile | No | `./Dockerfile` |
| `platforms` | Target platforms for build | No | `linux/amd64,linux/arm64` |
| `push` | Push the image to registry | No | `true` |
| `registry-username` | Username for registry authentication | No | `${{ github.actor }}` |
| `registry-password` | Password for registry authentication | No | `${{ github.token }}` |

## Outputs

| Output | Description |
|--------|-------------|
| `image` | Full image name with tags |
| `digest` | Image digest |

## Examples

### Using with Docker Hub

```yaml
- uses: RevoTale/docker-release-action@v1
with:
registry: docker.io
image-name: my-app
image-prefix: myusername/
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
```

### Build Only (No Push)

```yaml
- uses: RevoTale/docker-release-action@v1
with:
image-name: my-app
push: false
```

### Custom Platforms

```yaml
- uses: RevoTale/docker-release-action@v1
with:
image-name: my-app
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le
```

## Image Naming

The final image name is constructed as: `{registry}/{image-prefix}{image-name}`

Examples:
- `ghcr.io/my-app` (no prefix)
- `ghcr.io/myorg-my-app` (with prefix "myorg-")
- `docker.io/myusername/my-app` (Docker Hub with username as prefix)

## Examples

For more usage examples, see the [examples directory](./examples/) which contains:
- [Basic usage](./examples/basic-usage.yml)
- [Reusable workflow example](./examples/reusable-workflow.yml)
- [Docker Hub usage](./examples/docker-hub-usage.yml)

## License

MIT License - see [LICENSE](LICENSE) file for details.
Loading