diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..def5497 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,56 @@ +name: Build +on: + push: + branches: + - master + tags: + - "*" +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Checkout + uses: actions/checkout@v1 + + - name: Build + env: + CGO_ENABLED: 0 + run: go build -v + + - name: Run Tests + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: | + bash ./test.sh + bash <(curl -s https://codecov.io/bash) + + - name: Docker Login + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p '${{ secrets.DOCKER_PASSWORD }}' + + - name: Build Latest + if: github.ref == 'refs/heads/master' + run: | + docker build . -t coveo/credentials-sync:latest + docker push coveo/credentials-sync:latest + + - name: Build Tag + if: github.ref != 'refs/heads/master' + run: | + export tag=$(cut -d'/' -f3 <<<'${{ github.ref }}') + docker build . -t coveo/credentials-sync:$tag + docker push coveo/credentials-sync:$tag + + - name: Push release + if: github.ref != 'refs/heads/master' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl -sL https://git.io/goreleaser | bash; diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cae91ce..0000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -language: go - -go: "1.12.x" - -env: - - GO111MODULE=on CGO_ENABLED=0 - -install: - - go build - -script: - - bash ./test.sh - - bash <(curl -s https://codecov.io/bash) - -after_success: - # Login to dockerhub - - if [ "${TRAVIS_TAG::1}" = "v" ] || [ ${TRAVIS_BRANCH} == "master" ]; - then - docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"; - fi - # Push version images (on tag) - - if [ "${TRAVIS_TAG::1}" = "v" ]; - then - docker build . -t coveo/credentials-sync:${TRAVIS_TAG}; - docker push coveo/credentials-sync:${TRAVIS_TAG}; - fi - # Push latest version (on master) - - if [ ${TRAVIS_BRANCH} == "master" ]; - then - docker build . -t coveo/credentials-sync:latest; - docker push coveo/credentials-sync:latest; - fi - # Release version to Github (on tag) - - if [ "${TRAVIS_TAG::1}" = "v" ]; then - curl -sL https://git.io/goreleaser | bash; - fi \ No newline at end of file