Merge pull request #2584 from ashish-amarnath/github-actions
🏃♂️ Setup ci in github actions
pull/2586/head
commit
93612087d3
|
@ -1,5 +1,5 @@
|
||||||
name: Pull Request CI Check
|
name: Pull Request CI Check
|
||||||
on: [push, pull_request]
|
on: [pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
name: Push
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Set up Go 1.14
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.14
|
||||||
|
id: go
|
||||||
|
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: make local
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
- name: Publish container image
|
||||||
|
run: |
|
||||||
|
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
./hack/docker-push.sh
|
|
@ -20,8 +20,8 @@
|
||||||
|
|
||||||
set +x
|
set +x
|
||||||
|
|
||||||
if [[ -z "$TRAVIS" ]]; then
|
if [[ -z "$CI" ]]; then
|
||||||
echo "This script is intended to be run only on Travis." >&2
|
echo "This script is intended to be run only on Github Actions." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -47,37 +47,43 @@ function highest_release() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
triggeredBy=$(echo $GITHUB_REF | cut -d / -f 2)
|
||||||
|
if [[ "$triggeredBy" == "heads" ]]; then
|
||||||
|
BRANCH=$(echo $GITHUB_REF | cut -d / -f 3)
|
||||||
|
TAG=
|
||||||
|
elif [[ "$triggeredBy" == "tags" ]]; then
|
||||||
|
BRANCH=
|
||||||
|
TAG=$(echo $GITHUB_REF | cut -d / -f 3)
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$BRANCH" == "master" ]]; then
|
if [[ "$BRANCH" == "master" ]]; then
|
||||||
VERSION="$BRANCH"
|
VERSION="$BRANCH"
|
||||||
elif [[ ! -z "$TRAVIS_TAG" ]]; then
|
elif [[ ! -z "$TAG" ]]; then
|
||||||
# Tags aren't fetched by Travis on checkout, and we don't need them for master
|
# Explicitly checkout tags when building from a git tag.
|
||||||
|
# This is not needed when building from master
|
||||||
git fetch --tags
|
git fetch --tags
|
||||||
# Calculate the latest release if there's a tag.
|
# Calculate the latest release if there's a tag.
|
||||||
highest_release
|
highest_release
|
||||||
VERSION="$TRAVIS_TAG"
|
VERSION="$TAG"
|
||||||
else
|
else
|
||||||
# If we're not on master and we're not building a tag, exit early.
|
echo "We're not on master and we're not building a tag, exit early."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Assume we're not tagging `latest` by default, and never on master.
|
# Assume we're not tagging `latest` by default, and never on master.
|
||||||
TAG_LATEST=false
|
TAG_LATEST=false
|
||||||
if [[ "$BRANCH" == "master" ]]; then
|
if [[ "$BRANCH" == "master" ]]; then
|
||||||
echo "Building master, not tagging latest."
|
echo "Building master, not tagging latest."
|
||||||
elif [[ "$TRAVIS_TAG" == "$HIGHEST" ]]; then
|
elif [[ "$TAG" == "$HIGHEST" ]]; then
|
||||||
TAG_LATEST=true
|
TAG_LATEST=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Debugging info
|
# Debugging info
|
||||||
echo "Highest tag found: $HIGHEST"
|
echo "Highest tag found: $HIGHEST"
|
||||||
echo "BRANCH: $BRANCH"
|
echo "BRANCH: $BRANCH"
|
||||||
echo "TRAVIS_TAG: $TRAVIS_TAG"
|
echo "TAG: $TAG"
|
||||||
echo "TAG_LATEST: $TAG_LATEST"
|
echo "TAG_LATEST: $TAG_LATEST"
|
||||||
|
|
||||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
|
||||||
unset GIT_HTTP_USER_AGENT
|
|
||||||
|
|
||||||
echo "Building and pushing container images."
|
echo "Building and pushing container images."
|
||||||
|
|
||||||
VERSION="$VERSION" TAG_LATEST="$TAG_LATEST" make all-containers all-push all-manifests
|
VERSION="$VERSION" TAG_LATEST="$TAG_LATEST" make all-containers all-push all-manifests
|
||||||
|
|
Loading…
Reference in New Issue