Skip to content

Commit

Permalink
Add gh action for hotrod ci jobs
Browse files Browse the repository at this point in the history
Signed-off-by: Ashmita Bohara <ashmita.bohara152@gmail.com>
  • Loading branch information
Ashmita152 committed Dec 23, 2020
1 parent dad68d2 commit 2e01f59
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci-hotrod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CIT Hotrod

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
hotrod:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Fetch git tags
run: |
git fetch --prune --unshallow --tags
- uses: actions/setup-go@v2
with:
go-version: ^1.15

- uses: docker/login-action@v1
id: dockerhub-login
with:
username: jaegertracingbot
password: ${{ secrets.DOCKERHUB_TOKEN }}
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
if: env.DOCKERHUB_TOKEN != null

- name: Export DOCKERHUB_LOGIN variable
run: |
echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV
if: steps.dockerhub-login.outcome == 'success'

- name: Export BRANCH variable
uses: ./.github/actions/setup-branch

- name: Install tools
run: make install-ci

- name: Build, test, and publish hotrod image
run: bash scripts/travis/hotrod-integration-test.sh
10 changes: 5 additions & 5 deletions scripts/travis/hotrod-integration-test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash

set -e
set -euxf -o pipefail

make docker-hotrod
export REPO=jaegertracing/example-hotrod

export CID=$(docker run -d -p 8080:8080 $REPO:latest)
i=0
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080)" != "200" && ${i} < 5 ]]; do
Expand All @@ -19,13 +18,14 @@ fi
docker rm -f $CID

BRANCH=${BRANCH:?'missing BRANCH env var'}
# Only push images to Docker Hub for master branch or for release tags vM.N.P
if [[ ("$BRANCH" == "master" || $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$) && "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then
DOCKERHUB_LOGIN=${DOCKERHUB_LOGIN:-false}

# Only push images to Docker Hub for master branch or for release tags vM.N.P and when dockerhub login is done
if [[ ("$BRANCH" == "master" || $BRANCH =~ ^v[0-9]+\.[0-9]+\.[0-9]+$) && "$DOCKERHUB_LOGIN" == "true" ]]; then
echo "upload to Docker Hub, BRANCH=$BRANCH"
else
echo "skip Docker upload, only allowed for tagged releases or master (latest tag)"
exit 0
fi

bash ./scripts/travis/upload-to-docker.sh

0 comments on commit 2e01f59

Please sign in to comment.