mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-12 18:07:12 -04:00
Init
This commit is contained in:
15
Dockerfile
Normal file
15
Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
FROM docker
|
||||||
|
LABEL "com.github.actions.name"="Publish Docker"
|
||||||
|
LABEL "com.github.actions.description"="Uses the git branch as the docker tag and pushes the container"
|
||||||
|
LABEL "com.github.actions.icon"="anchor"
|
||||||
|
LABEL "com.github.actions.color"="blue"
|
||||||
|
|
||||||
|
LABEL "repository"="https://github.com/elgohr/Publish-Docker-Github-Action"
|
||||||
|
LABEL "maintainer"="Lars Gohr"
|
||||||
|
|
||||||
|
RUN apk update \
|
||||||
|
&& apk upgrade \
|
||||||
|
&& apk add --no-cache git
|
||||||
|
|
||||||
|
ADD entrypoint.sh /entrypoint.sh
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
38
README.md
38
README.md
@@ -1,2 +1,36 @@
|
|||||||
# Publish-Docker-Github-Action
|
# Publishes docker containers to Dockerhub
|
||||||
A Github Action which uses the Git branch as the Docker tag for pushing to DockerHub
|
|
||||||
|
This Action for [Docker](https://www.docker.com/) uses the Git branch as the Docker tag for building and pushing the container to DockerHub.
|
||||||
|
Hereby the master-branch is published as the latest-tag.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
An example workflow:
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
workflow "Publish Docker" {
|
||||||
|
on = "push"
|
||||||
|
resolves = ["logout"]
|
||||||
|
}
|
||||||
|
|
||||||
|
action "login" {
|
||||||
|
uses = "actions/docker/login@8cdf801b322af5f369e00d85e9cf3a7122f49108"
|
||||||
|
secrets = ["DOCKER_PASSWORD", "DOCKER_USERNAME"]
|
||||||
|
}
|
||||||
|
|
||||||
|
action "publish" {
|
||||||
|
uses = "actions/publish-docker@master"
|
||||||
|
args = "myDocker/repository"
|
||||||
|
needs = ["login"]
|
||||||
|
}
|
||||||
|
|
||||||
|
action "logout" {
|
||||||
|
uses = "actions/docker/cli@8cdf801b322af5f369e00d85e9cf3a7122f49108"
|
||||||
|
args = "logout"
|
||||||
|
needs = ["publish"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Argument
|
||||||
|
|
||||||
|
You need to provide the desired docker repository to the action.
|
||||||
|
|||||||
13
entrypoint.sh
Executable file
13
entrypoint.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh -l
|
||||||
|
|
||||||
|
echo ${GITHUB_REF}
|
||||||
|
BRANCH=$(${GITHUB_REF} | sed -e "s/refs\/heads\///g")
|
||||||
|
echo ${BRANCH}
|
||||||
|
if [ "${BRANCH}" = "master" ]; then
|
||||||
|
BRANCH="latest"
|
||||||
|
fi;
|
||||||
|
DOCKER_REPOSITORY=$*
|
||||||
|
DOCKERNAME="${DOCKER_REPOSITORY}:${BRANCH}"
|
||||||
|
|
||||||
|
docker build -t ${DOCKERNAME} .
|
||||||
|
docker push ${DOCKERNAME}
|
||||||
Reference in New Issue
Block a user