https://github.com/keptn/gh-action-build-docker-image
GH Action to Build Docker Images with some Keptn-internal improvements
https://github.com/keptn/gh-action-build-docker-image
Last synced: 26 days ago
JSON representation
GH Action to Build Docker Images with some Keptn-internal improvements
- Host: GitHub
- URL: https://github.com/keptn/gh-action-build-docker-image
- Owner: keptn
- License: apache-2.0
- Created: 2021-01-22T13:28:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-29T09:00:49.000Z (almost 4 years ago)
- Last Synced: 2025-05-12T19:15:28.495Z (26 days ago)
- Language: Shell
- Size: 18.6 KB
- Stars: 0
- Watchers: 13
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GH Action to Build Docker Images (with some Keptn internal stuff)
This repo provides a utility GitHub action for the [CI Workflow](https://github.com/keptn/keptn/tree/master/.github/workflows) in the [Keptn Project](https://github.com/keptn). Nevertheless, this action provides a very basic functionality, as in "Build a docker image and do some sanity checks".
## Inputs
* `IMAGE_NAME` - name of the image (including the docker organization)
* `DOCKER_FOLDER` (optional, defaults to './') - folder where Dockerfile is in; needs a trailing slash
* `VERSION` - semantic version used as the tag for the resulting image
* `DATETIME` (optional) - in case you want to build multiple images and refer to them with the same datetime string, e.g., YYYYMMDDHHmmss; (defaults to `DATETIME=$(date +'%Y%m%d%H%M')`)
* `FILE` (optional, defaults to 'Dockerfile') - name of the Dockerfile## Outputs
None at the moment
## Example usage
### Simple Example
```
env:
VERSION: "1.2.3"
steps:
- name: Checkout Code
uses: actions/checkout@v2- id: docker_login
name: Docker Login
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}- id: docker_build
name: Docker Build
uses: keptn/gh-action-build-docker-image@master
with:
PLATFORMS: ${{ env.DOCKER_PLATFORMS }}
VERSION: ${{ env.VERSION }}
IMAGE_NAME: "yourdockerorg/yourimagename"
```### Extended Example
```
env:
VERSION: "1.2.3"
steps:
- name: Checkout Code
uses: actions/checkout@v2- id: docker_login
name: Docker Login
# only run docker login on pushes; also for PRs, but only if this is not a fork
if: (github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == github.repository)
# note: GH does not allow to access secrets for PRs from a forked repositories due to security reasons
# that's fine, but it means we can't push images to dockerhub
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}- id: docker_build
name: Docker Build
uses: keptn/gh-action-build-docker-image@master
with:
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64"
VERSION: ${{ env.VERSION }}
IMAGE_NAME: "yourdockerorg/yourimagename"
DOCKER_FOLDER: "your-sub-directory/"
FILE: "your-dockerfile.Dockerfile"
```