Skip to content

Commit

Permalink
Determine how to tag image in cipublish script
Browse files Browse the repository at this point in the history
  • Loading branch information
colekettler committed Aug 17, 2021
1 parent 7a094a6 commit 4189923
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,8 @@ jobs:

- uses: codecov/codecov-action@v2

- run: |
echo "GIT_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "GIT_COMMIT=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
- run: ./scripts/cipublish
if: github.ref != 'refs/heads/master'
env:
IMAGE_VERSION: ${{ env.GIT_BRANCH }}
QUAY_USER: ${{ secrets.QUAY_RASTERVISION_USER }}
QUAY_PASSWORD: ${{ secrets.QUAY_RASTERVISION_PASSWORD }}

- run: ./scripts/cipublish
if: github.ref == 'refs/heads/master'
env:
IMAGE_VERSION: ${{ env.GIT_COMMIT }}
QUAY_USER: ${{ secrets.QUAY_RASTERVISION_USER }}
QUAY_PASSWORD: ${{ secrets.QUAY_RASTERVISION_PASSWORD }}

- run: ./scripts/cipublish
if: github.ref == 'refs/heads/master'
env:
IMAGE_VERSION: latest
QUAY_USER: ${{ secrets.QUAY_RASTERVISION_USER }}
QUAY_PASSWORD: ${{ secrets.QUAY_RASTERVISION_PASSWORD }}


36 changes: 30 additions & 6 deletions scripts/cipublish
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

if [[ -n ${RASTER_VISION_DEBUG} ]]; then
if [[ -n "${RASTER_VISION_DEBUG}" ]]; then
set -x
fi

Expand All @@ -13,14 +13,38 @@ Publish container images to Quay.io.
"
}

if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
if [[ ${1:-} == "--help" ]]; then
if [[ -n "${GITHUB_SHA}" ]]; then
GITHUB_SHA="${GITHUB_SHA:0:7}"
else
GITHUB_SHA="$(git rev-parse --short HEAD)"
fi

if [[ -z "${GITHUB_REF}" ]]; then
# We don't know where GitHub sources the value of GITHUB_REF. git-describe
# is close enough to be valid for publishing.
GITHUB_REF="$(git describe --all)"
fi

if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ "${1:-}" == "--help" ]]; then
usage
else
docker login -u="${QUAY_USER}" -p="${QUAY_PASSWORD}" quay.io

docker tag "raster-vision-${IMAGE_TYPE}" \
"quay.io/azavea/raster-vision:${IMAGE_TYPE}-${IMAGE_VERSION}"
docker push "quay.io/azavea/raster-vision:${IMAGE_TYPE}-${IMAGE_VERSION}"
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
# On master, use the current SHA and latest
docker tag "raster-vision-${IMAGE_TYPE}" \
"quay.io/azavea/raster-vision:${IMAGE_TYPE}-${GITHUB_SHA}"
docker push "quay.io/azavea/raster-vision:${IMAGE_TYPE}-${GITHUB_SHA}"

docker tag "raster-vision-${IMAGE_TYPE}" \
"quay.io/azavea/raster-vision:${IMAGE_TYPE}-latest"
docker push "quay.io/azavea/raster-vision:${IMAGE_TYPE}-latest"
else
# For everything else, use the branch or tag name
docker tag "raster-vision-${IMAGE_TYPE}" \
"quay.io/azavea/raster-vision:${IMAGE_TYPE}-${GITHUB_REF##*/}"
docker push "quay.io/azavea/raster-vision:${IMAGE_TYPE}-${GITHUB_REF##*/}"
fi
fi
fi

0 comments on commit 4189923

Please sign in to comment.