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: workflow_dispatch:
jobs: jobs:
build: build_push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Build Docker Image and Push
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: nelonoel/branch-name@v1.0.1 - uses: nelonoel/branch-name@v1.0.1
- name: Cache node modules - name: Cache node modules
uses: actions/cache@v2 uses: actions/cache@v2
env: env:
@ -23,17 +22,13 @@ jobs:
${{ runner.os }}-build- ${{ runner.os }}-build-
${{ runner.os }}- ${{ runner.os }}-
- name: Cache maven dependencies - name: Cache local Maven repository
uses: actions/cache@v2 uses: actions/cache@v2
env:
cache-name: cache-maven-deps
with: with:
path: ~/.m2 path: ~/.m2/repository
key: ${{ runner.os }}-build-${{ env.cache-name }} key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }} ${{ runner.os }}-maven-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Set up JDK 1.8 - name: Set up JDK 1.8
uses: actions/setup-java@v1 uses: actions/setup-java@v1
@ -45,17 +40,11 @@ jobs:
- name: Build with Maven - name: Build with Maven
run: mvn -B package --file pom.xml run: mvn -B package --file pom.xml
- name: Docker Setup Buildx - name: Push to Docker Hub
uses: docker/setup-buildx-action@v1.0.3 uses: docker/build-push-action@v1
- name: Docker Login
uses: docker/login-action@v1.6.0
with: with:
username: metersphere username: metersphere
password: ${{ secrets.DOCKER_HUB_TOKEN }} password: ${{ secrets.DOCKER_HUB_TOKEN }}
repository: metersphere/metersphere
- name: Build Docker Image tag_with_ref: true
uses: docker/build-push-action@v2.2.0 tag_with_sha: true
with:
build-args: MS_VERSION=${{ env.BRANCH_NAME }}-b${{ env.GITHUB_RUN_NUMBER }}
tags: metersphere/metersphere:${{ env.BRANCH_NAME }}