-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anze
committed
Dec 13, 2019
1 parent
eedda1a
commit c3ac21f
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Deploy to Docker Hub | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout source code | ||
uses: actions/checkout@v1 | ||
|
||
|
||
- name: Deploy to Docker Hub | ||
if: success() && startsWith(github.ref, 'refs/tags/v') | ||
env: | ||
GITHUB_REF_TAG: ${{ github.ref }} | ||
DOCKER_REGISTRY: docker.io | ||
DOCKER_IMAGE: grafolean/grafolean-snmp-bot | ||
DOCKER_USER: grafolean | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
export VERSION=${GITHUB_REF_TAG:10:50} | ||
echo "Version is $VERSION" | ||
export LAST_KNOWN_VERSION=`git tag -l --sort=-version:refname "v*.*.*" | grep -v rc | head -n 1 | tr -d '[:space:]'` | ||
echo "Last known version is $LAST_KNOWN_VERSION" | ||
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD $DOCKER_REGISTRY | ||
docker build -t "docker.io/$DOCKER_IMAGE:$VERSION" -t "docker.io/$DOCKER_IMAGE:latest" --build-arg VERSION=$VERSION --build-arg VCS_REF=$GITHUB_SHA --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') . | ||
[ "$LAST_KNOWN_VERSION" == "$VERSION" ] && docker tag "docker.io/$DOCKER_IMAGE:$VERSION" "docker.io/$DOCKER_IMAGE:latest" || echo "NOT MARKING AS LATEST!" | ||
docker images | ||
docker push "docker.io/$DOCKER_IMAGE:$VERSION" | ||
[ "$LAST_KNOWN_VERSION" == "$VERSION" ] && docker push "docker.io/$DOCKER_IMAGE:latest" || echo "NOT LATEST!" |