From 9e4082720ea9afef327cbff9b336c588b43670f0 Mon Sep 17 00:00:00 2001 From: BugKing Date: Thu, 3 Dec 2020 18:15:40 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E6=9B=B4=E6=96=B0=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-push.yml | 37 +++++++++++--------------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 8b27575860..4a629f55fc 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -4,13 +4,12 @@ on: workflow_dispatch: jobs: - build: + build_push: runs-on: ubuntu-latest - + name: Build Docker Image and Push steps: - uses: actions/checkout@v2 - uses: nelonoel/branch-name@v1.0.1 - - name: Cache node modules uses: actions/cache@v2 env: @@ -23,17 +22,13 @@ jobs: ${{ runner.os }}-build- ${{ runner.os }}- - - name: Cache maven dependencies + - name: Cache local Maven repository uses: actions/cache@v2 - env: - cache-name: cache-maven-deps with: - path: ~/.m2 - key: ${{ runner.os }}-build-${{ env.cache-name }} + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }} - ${{ runner.os }}-build- - ${{ runner.os }}- + ${{ runner.os }}-maven- - name: Set up JDK 1.8 uses: actions/setup-java@v1 @@ -43,19 +38,13 @@ jobs: settings-path: ${{ github.workspace }} # location for the settings.xml file - name: Build with Maven - run: mvn -B package --file pom.xml - - - name: Docker Setup Buildx - uses: docker/setup-buildx-action@v1.0.3 - - - name: Docker Login - uses: docker/login-action@v1.6.0 + run: mvn -B package --file pom.xml + + - name: Push to Docker Hub + uses: docker/build-push-action@v1 with: username: metersphere password: ${{ secrets.DOCKER_HUB_TOKEN }} - - - name: Build Docker Image - uses: docker/build-push-action@v2.2.0 - with: - build-args: MS_VERSION=${{ env.BRANCH_NAME }}-b${{ env.GITHUB_RUN_NUMBER }} - tags: metersphere/metersphere:${{ env.BRANCH_NAME }} + repository: metersphere/metersphere + tag_with_ref: true + tag_with_sha: true