From 2e01f59edd2aef3f3a8d345f13713d03d9e33d9d Mon Sep 17 00:00:00 2001 From: Ashmita Bohara Date: Wed, 23 Dec 2020 23:04:31 +0800 Subject: [PATCH] Add gh action for hotrod ci jobs Signed-off-by: Ashmita Bohara --- .github/workflows/ci-hotrod.yml | 46 +++++++++++++++++++++++ scripts/travis/hotrod-integration-test.sh | 10 ++--- 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci-hotrod.yml diff --git a/.github/workflows/ci-hotrod.yml b/.github/workflows/ci-hotrod.yml new file mode 100644 index 00000000000..e94e037026d --- /dev/null +++ b/.github/workflows/ci-hotrod.yml @@ -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 diff --git a/scripts/travis/hotrod-integration-test.sh b/scripts/travis/hotrod-integration-test.sh index 6abddfa9f03..b5b0603615f 100755 --- a/scripts/travis/hotrod-integration-test.sh +++ b/scripts/travis/hotrod-integration-test.sh @@ -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 @@ -19,8 +18,10 @@ 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)" @@ -28,4 +29,3 @@ else fi bash ./scripts/travis/upload-to-docker.sh -