From bf21a3724c904576307f9be887d7242c3e26c924 Mon Sep 17 00:00:00 2001 From: Adam Otto Date: Wed, 4 Nov 2020 15:19:06 +0100 Subject: [PATCH 1/3] initial github workflow definition --- .github/workflows/main.yml | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..7f2cb95 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,63 @@ +name: ci + +on: + push: + branches: + - "*" # run for branches + tags: + - "*" # run for tags + pull_request: + branches: + - "*" # run for branches + tags: + - "*" # run for tags + +jobs: + test: + runs-on: ubuntu-latest + env: + GROUP: weaveworksdemos + COMMIT: ${{ github.sha }} + REPO: shipping + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Build with Maven + run: mvn -B -DskipTests package --file pom.xml + + - name: Unit Tests + run: mvn -q test + + - name: Integration Tests + run: mvn integration-test + + # Upload coverage results to coveralls + - name: Submit Coveralls + env: + COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: mvn -DrepoToken=${COVERALLS_TOKEN} -DserviceJobId=${GITHUB_RUN_ID} -Dbranch=${GITHUB_REF} -DpullRequest=${GITHUB_HEAD_REF} -DserviceName=GITHUB verify jacoco:report coveralls:report + + # Push to dockerhub + - name: Push to Docker Hub + uses: docker/build-push-action@v1 +# if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + dockerfile: docker/shipping/Dockerfile + path: target/ + repository: ${{ env.GROUP }}/${{ env.REPO }} + tag_with_ref: true + tag_with_sha: true From 7b0dad5159a05de4bf7bff6d6f81c1e89aeef2c8 Mon Sep 17 00:00:00 2001 From: Adam Otto Date: Wed, 4 Nov 2020 15:32:34 +0100 Subject: [PATCH 2/3] add coveralls token --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f2cb95..ea47a16 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,7 +46,7 @@ jobs: # Upload coverage results to coveralls - name: Submit Coveralls env: - COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }} run: mvn -DrepoToken=${COVERALLS_TOKEN} -DserviceJobId=${GITHUB_RUN_ID} -Dbranch=${GITHUB_REF} -DpullRequest=${GITHUB_HEAD_REF} -DserviceName=GITHUB verify jacoco:report coveralls:report # Push to dockerhub From e0e2b32ecf788d30d1776bfbebec469be2c2ed78 Mon Sep 17 00:00:00 2001 From: Adam Otto Date: Wed, 4 Nov 2020 15:36:27 +0100 Subject: [PATCH 3/3] undo comment on docker push --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ea47a16..5915631 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,7 @@ jobs: # Push to dockerhub - name: Push to Docker Hub uses: docker/build-push-action@v1 -# if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' + if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASS }}