Maven Build in < 20 lines of yaml

Maven Tips (2 Part Series)

1 Maven Build in < 20 lines of yaml
2 Default Maven and Java settings per project

GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

Create the directory

$ mkdir -p .github/workflows
$ mkdir -p .github/workflows
$ mkdir -p .github/workflows

Enter fullscreen mode Exit fullscreen mode

Create the yaml file

$ touch .github/workflows/maven.yml
$ touch .github/workflows/maven.yml
$ touch .github/workflows/maven.yml

Enter fullscreen mode Exit fullscreen mode

Copy this content

name: Maven Build
on:
push:
branches:
- main
jobs:
build:
name: "Maven Build"
runs-on: ubuntu-latest
steps:
- name: "Checkout Sources"
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: "Set up JDK"
uses: actions/setup-java@v2
with:
distribution: "temurin"
java-version: 11
cache: "maven"
- name: "Build with Maven"
run: mvn verify
name: Maven Build
on:
  push:
    branches:
      - main
jobs:
  build:
    name: "Maven Build"
    runs-on: ubuntu-latest
    steps:
      - name: "Checkout Sources"
        uses: actions/checkout@v2
        with:
          fetch-depth: 2
      - name: "Set up JDK"
        uses: actions/setup-java@v2
        with:
          distribution: "temurin"
          java-version: 11
          cache: "maven"
      - name: "Build with Maven"
        run: mvn verify
name: Maven Build on: push: branches: - main jobs: build: name: "Maven Build" runs-on: ubuntu-latest steps: - name: "Checkout Sources" uses: actions/checkout@v2 with: fetch-depth: 2 - name: "Set up JDK" uses: actions/setup-java@v2 with: distribution: "temurin" java-version: 11 cache: "maven" - name: "Build with Maven" run: mvn verify

Enter fullscreen mode Exit fullscreen mode

Commit and push to Github

$ git add .github && \
git commit -m "maven build action"
$ git add .github && \
  git commit -m "maven build action"
$ git add .github && \ git commit -m "maven build action"

Enter fullscreen mode Exit fullscreen mode

Enjoy your builds

Go to the actions tab for your repository over github.com:

https://github.com/${USER}/${PROJECT}/actions/workflows/maven-build.yml

Maven Tips (2 Part Series)

1 Maven Build in < 20 lines of yaml
2 Default Maven and Java settings per project

原文链接: Maven Build in < 20 lines of yaml

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
Judge each day not by the harvest you reap but by the seeds you plant.
不要问自己收获了多少果实,而是要问自己今天播种了多少种子
评论 抢沙发

请登录后发表评论

    暂无评论内容