diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml new file mode 100644 index 0000000000..0220027a94 --- /dev/null +++ b/.github/workflows/build-push.yml @@ -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}