https://github.com/paritytech/build-n-push-action
GitHub Action is designed to build a Docker image from a specified Dockerfile and, optionally, push it to a Docker registry.
https://github.com/paritytech/build-n-push-action
Last synced: 3 months ago
JSON representation
GitHub Action is designed to build a Docker image from a specified Dockerfile and, optionally, push it to a Docker registry.
- Host: GitHub
- URL: https://github.com/paritytech/build-n-push-action
- Owner: paritytech
- License: mit
- Created: 2024-10-01T11:54:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-23T13:53:59.000Z (about 1 year ago)
- Last Synced: 2026-01-15T15:33:59.502Z (5 months ago)
- Size: 13.7 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Build Action
This GitHub Action is designed to build a Docker image from a specified Dockerfile and, optionally, push it to a Docker registry.
## Usage
To use this action in your workflow, add the following step to your GitHub Actions workflow file (e.g., `.github/workflows/build.yml`):
```yaml
- name: Build and Push Docker Image
uses: paritytech/build-n-push-action@main
with:
push_to_registry: "true" # or 'false' if you do not wish to push (for example if you testing build without pushing to registry)
registry_user: ${{ secrets.REGISTRY_USER }}
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
registry_url: "registry.parity.io/parity-internal/" # optional, defaults to 'registry.parity.io/parity-internal/'
image_name: "your-image-name" # optional, defaults to GitHub repository
image_tags: "latest v1.3.0"
dockerfile_path: "./path/to/Dockerfile" # optional, defaults to './Dockerfile'
build_args: | # optional
ARG1=value1
ARG2=value2
context: "./path/to/context" # optional, defaults to '.'
```
## Inputs
| Name | Description | Required | Default |
| ------------------- | -------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------ |
| `push_to_registry` | Whether to push the image to registry ('true' or 'false' as string). | Yes | N/A |
| `registry_user` | Registry username (if push_to_registry is 'true'). | No | N/A |
| `registry_password` | Registry password (if push_to_registry is 'true'). | No | N/A |
| `registry_url` | Registry url. | No | 'registry.parity.io/parity-internal/' |
| `image_name` | Image name. | No | GitHub repository name |
| `image_tags` | Image tags. | No | Either tag github.ref_name if triggered by tag or github.sha (space separated) |
| `dockerfile_path` | Dockerfile path. | No | './Dockerfile' |
| `build_args` | Build arguments. Default includes VCS_REF and BUILD_DATE. | No | VCS_REF=${{ github.sha }}
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ') |
| `extra_args` | Extra Build arguments. | No | Like --target layer_1 |
| `context` | Build context. | No | '.' |
## Outputs
- `tag`: The tag of the built image.
## Example Workflow
Here's a complete example of a workflow using this action:
```yaml
name: Build and Deploy
on:
push:
branches: - main
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build and Push Docker Image
uses: paritytech/build-n-push-action@main
with:
push_to_registry: "true"
registry_user: ${{ secrets.REGISTRY_USER }}
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
```