forked from ghostec/Will.IAM
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
4 changed files
with
122 additions
and
38 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 |
---|---|---|
@@ -1,16 +1,25 @@ | ||
language: go | ||
go: | ||
- '1.13' | ||
services: | ||
- docker | ||
cache: | ||
directories: | ||
- "$GOPATH/pkg" | ||
before_install: | ||
- go get github.com/mattn/goveralls | ||
install: | ||
- make ci/install | ||
script: | ||
- make ci/test | ||
after_success: | ||
- goveralls -coverprofile=coverage.out -service=travis-ci | ||
|
||
go: '1.13' | ||
|
||
jobs: | ||
include: | ||
- stage: test | ||
cache: | ||
directories: | ||
- "$GOPATH/pkg" | ||
services: | ||
- docker | ||
before_install: | ||
- go get github.com/mattn/goveralls | ||
install: | ||
- make ci/install | ||
after_success: | ||
- goveralls -coverprofile=coverage.out -service=travis-ci | ||
script: | ||
- make ci/test | ||
- stage: deploy | ||
if: tag IS present | ||
services: docker | ||
script: | ||
- sh ./push_to_docker.sh |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,33 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
readonly DOCKER_HUB_REPO='tfgco/will-iam' | ||
readonly TRAVIS_TAG="${TRAVIS_TAG:-}" | ||
|
||
docker_tag_exists() { | ||
local repo="$1" | ||
local tag="$2" | ||
curl --silent -flSL "https://index.docker.io/v1/repositories/$repo/tags/$tag" > /dev/null | ||
} | ||
|
||
main() { | ||
local last_commit_sha | ||
last_commit_sha=$(git rev-parse --short HEAD) | ||
|
||
if docker_tag_exists "$DOCKER_HUB_REPO" "$TRAVIS_TAG"; then | ||
echo "An image with the version $TRAVIS_TAG already exists in Docker Hub. Please update your version.txt file and try again." | ||
exit 1 | ||
fi | ||
|
||
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" | ||
docker build -t will-iam . | ||
docker tag will-iam "$DOCKER_HUB_REPO:$last_commit_sha" | ||
docker tag will-iam "$DOCKER_HUB_REPO:$TRAVIS_TAG" | ||
docker push "$DOCKER_HUB_REPO:$last_commit_sha" | ||
docker push "$DOCKER_HUB_REPO:$TRAVIS_TAG" | ||
|
||
curl -X POST "$TEST_FARM_URL&version=$TRAVIS_TAG" | ||
} | ||
|
||
main "$@" |