Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
(#41) Fix Publish Docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Sobolev committed Jun 30, 2020
1 parent 3ff1b7f commit 8169cec
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
51 changes: 51 additions & 0 deletions .github/scripts/PublishDocker.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# A script to decide what version to upload

# Set current repository variable
REPOSITORY=paveloom-d/dev

# Get last published version
LAST_VERSION=$(curl --silent "https://api.github.com/repos/$REPOSITORY/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

# Check if there is some tag
if [ ! -z "$LAST_VERSION" ]; then

# Get current tag
CURRENT_TAG=$(echo ${GITHUB_REF#refs/*/})

# Print info
echo -e "\n\e[1m\033[36mLast version: $LAST_VERSION\033[0m"
echo -e "\e[1m\033[36mCurrent tag: $CURRENT_TAG\033[0m\n"

# Check if the tag is a semantic version
if echo "$CURRENT_TAG" | grep -q "v[0-9]*.[0-9]*.[0-9]*"; then

# Print information
echo -e "\e[1m\033[36mCurrent tag is a semantic version. Tagged image will be published.\033[0m\n"

# Set environment variable
echo ::set-env name=RELEASE_VERSION::$(echo ${CURRENT_TAG} | sed 's/v//')

# Publish tagged image
echo ::set-env name=PUBLISH_RELEASE_VERSION::$(echo true)

else

# Print information
echo -e "\e[1m\033[36mCurrent tag is not a semantic version. Tagged image will not be published.\033[0m\n"

# Don't publish tagged image
echo ::set-env name=PUBLISH_RELEASE_VERSION::$(echo false)

fi

else

# Print information
echo -e "\n\e[1m\033[36mNo release has been found, tagged version will not be published.\033[0m\n"

# Don't publish tagged image
echo ::set-env name=PUBLISH_RELEASE_VERSION::$(echo false)

fi
2 changes: 1 addition & 1 deletion .github/scripts/VersionCheck.bash
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ get_latest_release() {
# and Semantic Versioning was respected)
LAST_VERSION=$(get_latest_release "paveloom-d/dev")

# Check if there is a some tag
# Check if there is some tag
if [ ! -z "$LAST_VERSION" ]; then

# Escape last version
Expand Down
19 changes: 15 additions & 4 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Get release version
id: get_version
run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:10})
- name: Publish to Registry
run: bash .github/scripts/PublishDocker.bash

- name: Publish to Registry (with tagged image)
if: ${{ env.PUBLISH_RELEASE_VERSION == 'true' }}
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: paveloom-d/dev/dev
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
tags: "latest,${{ env.RELEASE_VERSION }}"

- name: Publish to Registry (without tagged image)
if: ${{ env.PUBLISH_RELEASE_VERSION == 'false' }}
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: paveloom-d/dev/dev
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
tags: "latest,${{ env.RELEASE_VERSION }}"
tags: "latest"

0 comments on commit 8169cec

Please sign in to comment.