Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github action for jaeger packages and docker image #2740

Merged
merged 7 commits into from
Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup-branch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ runs:
pull_request)
BRANCH=${GITHUB_HEAD_REF}
;;
push)
push | release)
BRANCH=${GITHUB_REF##*/}
;;
esac
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/ci-build-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build binaries

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

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

- name: Fetch git tags
run: |
git fetch --prune --unshallow --tags
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this step when building binaries?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, when we do need tags, can we achieve the same effect with this setting?

    # Number of commits to fetch. 0 indicates all history for all branches and tags.
    # Default: 1
    fetch-depth: ''

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we want to pull tags as part of checkout action, only option from my understanding is to set fetch-depth: 0 which will also fetch all the commit history of all branches which will increase build time. I'm unable to find an option for just pulling the tags without commit history.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it's worth creating a PR for the official action to add a new parameter like tags:


- uses: actions/setup-go@v2
with:
go-version: ^1.15

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

- name: Install tools
run: make install-ci

- name: Build binaries
run: make build-all-platforms
53 changes: 53 additions & 0 deletions .github/workflows/ci-docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build docker images

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

jobs:
docker-images:
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: actions/setup-node@v2-beta
with:
node-version: '10'

- 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 docker images
run: make docker

- name: Upload docker images
run: bash scripts/travis/upload-all-docker-images.sh
71 changes: 71 additions & 0 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Publish release

on:
release:
types:
- published

jobs:
publish-release:
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: actions/setup-node@v2-beta
with:
node-version: '10'

- 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 binaries
run: make build-all-platforms

- name: Package binaries
Ashmita152 marked this conversation as resolved.
Show resolved Hide resolved
run: bash scripts/travis/package-deploy.sh
env:
DEPLOY: true
Ashmita152 marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload binaries
Ashmita152 marked this conversation as resolved.
Show resolved Hide resolved
uses: svenstaro/upload-release-action@v2
with:
file: deploy/*.tar.gz
file_glob: true
tag: ${{ github.ref }}
repo_token: ${{ secrets.GITHUB_TOKEN }}

- name: Build docker images
run: make docker

- name: Upload docker images
Ashmita152 marked this conversation as resolved.
Show resolved Hide resolved
run: bash scripts/travis/upload-all-docker-images.sh

- name: Build, test, and publish all-in-one image
run: bash scripts/travis/build-all-in-one-image.sh
6 changes: 0 additions & 6 deletions scripts/travis/package-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ function package {
rm -rf $PACKAGE_STAGING_DIR
}

# script start
if [ "$DEPLOY" != true ]; then
echo "Skipping the packaging of binaries as \$DEPLOY was not true."
exit 0
fi

set -e

DEPLOY_STAGING_DIR=./deploy-staging
Expand Down
14 changes: 5 additions & 9 deletions scripts/travis/upload-all-docker-images.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#!/bin/bash

# this script should only be run after build-docker-images.sh
# this script expects all docker images to be already built, it only uploads them to Docker Hub

set -e
set -euxf -o pipefail

BRANCH=${BRANCH:?'missing BRANCH env var'}
DOCKERHUB_LOGIN=${DOCKERHUB_LOGIN:-false}

if [[ "$TRAVIS_SECURE_ENV_VARS" == "false" ]]; then
echo "skip docker upload, TRAVIS_SECURE_ENV_VARS=$TRAVIS_SECURE_ENV_VARS"
exit 0
fi

# 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]+$ ]]; then
# 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)'
Expand Down