build: 增加 GitHub action

This commit is contained in:
BugKing 2020-12-03 14:41:42 +08:00 committed by GitHub
parent bf13f09322
commit ad72116159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

36
.github/workflows/build-push.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Build Docker Image and Push
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: nelonoel/branch-name@v1.0.1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
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
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build Docker Image
uses: docker/build-push-action@v2.2.0
with:
build-args: MS_VERSION=${BRANCH_NAME}-b${GITHUB_RUN_NUMBER}
tags: metersphere/metersphere:${BRANCH_NAME}