MeterSphere/.github/workflows/build-push.yml

60 lines
1.7 KiB
YAML
Raw Normal View History

2020-12-03 14:41:42 +08:00
name: Build Docker Image and Push
on:
2020-12-03 19:18:08 +08:00
push:
branches:
2020-12-03 19:37:06 +08:00
- master
- v1*
2020-12-03 19:37:06 +08:00
workflow_dispatch:
2020-12-03 14:41:42 +08:00
jobs:
2020-12-03 18:15:40 +08:00
build_push:
2020-12-03 14:41:42 +08:00
runs-on: ubuntu-latest
2020-12-03 18:15:40 +08:00
name: Build Docker Image and Push
2020-12-03 14:41:42 +08:00
steps:
- uses: actions/checkout@v2
2020-12-03 19:57:16 +08:00
with:
submodules: true
2020-12-03 20:09:44 +08:00
token: ${{ secrets.ACCESS_TOKEN }}
2020-12-03 19:57:16 +08:00
2020-12-03 19:18:08 +08:00
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
2020-12-03 15:12:28 +08:00
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
2020-12-03 18:15:40 +08:00
- name: Cache local Maven repository
2020-12-03 15:12:28 +08:00
uses: actions/cache@v2
with:
2020-12-03 18:15:40 +08:00
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
2020-12-03 15:12:28 +08:00
restore-keys: |
2020-12-03 18:15:40 +08:00
${{ runner.os }}-maven-
2020-12-03 15:12:28 +08:00
2020-12-03 14:41:42 +08:00
- 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
2020-12-03 18:15:40 +08:00
run: mvn -B package --file pom.xml
- name: Push to Docker Hub
uses: docker/build-push-action@v1
2020-12-03 14:41:42 +08:00
with:
username: metersphere
2020-12-03 14:41:42 +08:00
password: ${{ secrets.DOCKER_HUB_TOKEN }}
2020-12-03 18:15:40 +08:00
repository: metersphere/metersphere
tags: ${{ env.GITHUB_REF_SLUG }}
2020-12-03 19:37:06 +08:00
build_args: MS_VERSION=${{ env.GITHUB_REF_SLUG }}-${{ env.GITHUB_SHA_SHORT }}