diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b79a4a4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: Learn Layer5 + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + docker: + name: Docker build and push + runs-on: ubuntu-latest + steps: + - name: Check out code + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') && success() + uses: actions/checkout@master + with: + fetch-depth: 1 + - name: Docker login + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') && success() + uses: azure/docker-login@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Docker build & push + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') && success() + run: | + make build-img-service + make image-push diff --git a/Makefile b/Makefile index e13a42c..7a97123 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +VER=$(shell git rev-parse --short HEAD) + build-service: cd service && go build -a -o ./main . @@ -12,4 +14,7 @@ run-service-b: ./service/main build-img-service: - cd service && docker build -t layer5/sample-app-service:dev . + cd service && docker build -t layer5/learn-layer5:latest -t layer5/learn-layer5:$(VER) . + +image-push: + docker push layer5/learn-layer5