build: 更新 action

This commit is contained in:
BugKing 2020-12-03 18:15:40 +08:00
parent 71d11f0fb7
commit 9e4082720e
1 changed files with 13 additions and 24 deletions

View File

@ -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