Skip to content

Commit

Permalink
Added push to docker hub
Browse files Browse the repository at this point in the history
  • Loading branch information
WoLfulus committed Oct 1, 2020
1 parent 70f573d commit 03b9327
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
15 changes: 10 additions & 5 deletions .github/actions/build-images/rootfs/usr/bin/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function main() {
push=$(argument push "false")
latest=$(argument latest "false")

registry=$(argument registry "ghcr.io")
registry=$(argument registry "")
registry=$(echo "${registry}" | tr '[:upper:]' '[:lower:]')

repository=$(argument repository "directus/next")
Expand All @@ -75,6 +75,11 @@ function main() {
version=$(argument version "")
context=$(argument context ".")

image="${repository}"
if [ "${registry}" != "" ]; then
image="${registry}/${image}"
fi

# Normalize tag
if [ "${version}" == "" ]; then
version=${GITHUB_REF##*/}
Expand Down Expand Up @@ -102,7 +107,7 @@ function main() {
# Push latest
# TODO: check if it's really the latest
if [ "${latest}" == "true" ]; then
fqin="${registry}/${repository}:latest"
fqin="${image}:latest"
echo "Tagging ${fqin}"
docker tag directus:main ${fqin}
if [ "${push}" == "true" ]; then
Expand All @@ -115,12 +120,12 @@ function main() {
for tag in $tags
do
tag=$(echo "${tag}" | tr '[:upper:]' '[:lower:]')
fqin="${registry}/${repository}:latest"
fqin="${image}:${tag}"
echo "Tagging ${fqin}"
docker tag directus:main "${registry}/${repository}:${tag}"
docker tag directus:main "${fqin}"
if [ "${push}" == "true" ]; then
echo "Pushing tag ${fqin}"
docker push "${registry}/${repository}:${tag}"
docker push "${fqin}"
fi
done

Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Build
- name: Build GitHub Container Registry
uses: ./.github/actions/build-images
with:
registry: "ghcr.io"
Expand All @@ -20,3 +20,12 @@ jobs:
password: "${{ secrets.REGISTRY_PASSWORD }}"
version: "${{ github.ref }}"
push: "true"

- name: Build Docker Hub
uses: ./.github/actions/build-images
with:
repository: "${{ github.repository }}"
username: "${{ secrets.DOCKERHUB_USERNAME }}"
password: "${{ secrets.DOCKERHUB_PASSWORD }}"
version: "${{ github.ref }}"
push: "true"

0 comments on commit 03b9327

Please sign in to comment.