From 7bddfee4db0d65809dad0ee3f0a4470ebd596ab3 Mon Sep 17 00:00:00 2001 From: Vincent Boutour Date: Tue, 3 Nov 2020 14:11:49 +0100 Subject: [PATCH] ci: Migrating to Github Action --- .github/workflows/build.yml | 59 +++++++++++++++++++++++++++++++++++++ .travis.yml | 26 ---------------- Dockerfile | 12 -------- README.md | 2 +- 4 files changed, 60 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..709e46c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,59 @@ +--- +name: Build + +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + SCRIPTS_NO_INTERACTIVE: "true" + +defaults: + run: + shell: bash + +jobs: + build: + name: Golang + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: "^1.15" + - run: | + make + git --no-pager diff -- ':(exclude)go.sum' && git diff --quiet -- ':(exclude)go.sum' + docker build "APP_VERSION=$(make version)" -t "${{ secrets.DOCKER_USER }}/$(make name):$(make version)" . + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + - run: | + docker push "${{ secrets.DOCKER_USER }}/$(make name):$(make version)" + - uses: codecov/codecov-action@v1 + + publish: + name: Publish + runs-on: ubuntu-latest + needs: package + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + steps: + - uses: actions/checkout@v2 + - name: Publish + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + run: | + curl -q -sSL --max-time 30 "https://raw.githubusercontent.com/ViBiOh/scripts/master/bootstrap" | bash -s "docker_promote" + scripts/docker_promote "${{ secrets.DOCKER_USER }}/$(make name)" "$(make version)" + - name: GoReport + run: | + curl -q -sSL --max-time 30 -X POST https://goreportcard.com/checks?repo=github.com/${GITHUB_REPOSITORY} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f83cf48..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -jobs: - include: - - stage: Build - language: minimal - services: - - docker - script: docker build --build-arg CODECOV_TOKEN --build-arg "APP_VERSION=$(make version)" -t "${DOCKER_USER}/$(make name):$(make version)" . - after_success: - - echo "${DOCKER_PASS}" | docker login -u "${DOCKER_USER}" --password-stdin - - docker push "${DOCKER_USER}/$(make name):$(make version)" - - - stage: Publish - language: minimal - script: - - curl -q -sSL --max-time 30 "https://raw.githubusercontent.com/ViBiOh/scripts/master/bootstrap" | bash -s "docker_promote" - - scripts/docker_promote "${DOCKER_USER}/$(make name)" "$(make version)" - after_success: - - curl -q -sSL --max-time 30 -X POST https://goreportcard.com/checks?repo=github.com/${TRAVIS_REPO_SLUG} - -stages: - - Build - - name: Publish - if: branch = master && type = push -notifications: - email: false diff --git a/Dockerfile b/Dockerfile index 37cce04..a2ab7e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,3 @@ -FROM golang:1.15 as builder - -WORKDIR /app -COPY . . - -RUN make \ - && git diff -- *.go \ - && git diff --quiet -- *.go - -ARG CODECOV_TOKEN -RUN curl -q -sSL --max-time 30 https://codecov.io/bash | bash - FROM docker/compose:1.27.4 EXPOSE 1080 diff --git a/README.md b/README.md index 2bcb1a5..c6bf653 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # deploy -[![Build Status](https://travis-ci.com/ViBiOh/deploy.svg?branch=master)](https://travis-ci.com/ViBiOh/deploy) +[![Build](https://github.com/ViBiOh/deploy/workflows/Build/badge.svg)](https://github.com/ViBiOh/deploy/actions) [![Go Report Card](https://goreportcard.com/badge/github.com/ViBiOh/deploy)](https://goreportcard.com/report/github.com/ViBiOh/deploy) [![codecov](https://codecov.io/gh/ViBiOh/deploy/branch/master/graph/badge.svg)](https://codecov.io/gh/ViBiOh/deploy) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FViBiOh%2Fdeploy.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FViBiOh%2Fdeploy?ref=badge_shield)