A GitHub Action to easly build docker image and push to the registry.
You can use this action after any other action. Here is an example setup of this action:
- Create a
.github/workflows/docker-build.ymlfile in your GitHub repo. - Add the following code to the
docker-build.ymlfile.
on: push
name: Build docker Demo
jobs:
slackNotification:
name: Build docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build docker
uses: pmagentur/pm_docker_builder@v0.1
env:
USERNAME: ${{ secrets.USERNAME }}
PASSWORD: ${{ secrets.PASSWORD }}
CREATE_BACKUP: "True"
- Create
USERNAMEandPASSWORDsecrets GitHub Action's Secret, which represent Your Docker's registry username and password
By default, action is designed to run with minimal configuration but you can alter Slack notification using following environment variables:
| Variable | Default | Purpose |
|---|---|---|
| USERNAME | Must be passed as an env variable | Docker registry username |
| PASSWORD | GitHub Repository name | Docker registry password |
| REGISTRY | hub.docker.com |
Docker registry url (public or private) |
| REPOSITORY | GitHub Repo name excluding owner name , If octocat/Hello-World, then REPOSITORY=Hello-World |
Docker repository name (IMAGE = (REGISTRY/REPOSITORY:TAG)) |
| TAG | latest |
Docker image's tag |
| DOCKERFILE_PATH | . |
The location of the Dockerfile (Same as CONTEXT_PATH, if both are defined CONTEXT_PATH is used) |
| CREATE_BACKUP | False |
If it is set to True, Action Creates doublicated docker image using build number as a tag and puses to docker registry |
| CONTEXT_PATH | $DOCKERFILE_PATH |
Sets the build context directory (Same as DOCKERFILE_PATH, if both are defined CONTEXT_PATH is used) |
| DOCKERFILE | $CONTEXT_PATH + '/Dockerfile' |
Defines the dockerfile which will be used for the build |
You can see the action block with all variables as below:
- name: Slack notifier
uses: pmagentur/pm_slack_notifier@v0.1
env:
USERNAME: ${{ secrets.USERNAME }}
PASSWORD: ${{ secrets.PASSWORD }}
REGISTRY: docker.pmagenture.com
REPOSITORY: 'pm-test-image'
CONTEXT_PATH: '..'
DOCKERFILE: './Dockerfile.stage'
CREATE_BACKUP: 'True'MIT © 2019 PM Agentur