diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 000000000..ad960de7e --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,81 @@ +name: Merge request pipeline + +on: + pull_request: + branches: [ main ] + +jobs: + checkstyle: + + runs-on: ubuntu-latest + container: + image: maven:3.8.5-openjdk-17 + steps: + - + name: Checkout code + uses: actions/checkout@v4 + + - + name: Run checkstyle w/ Gradle + run: ./gradlew checkstyleMain + + - + name: Upload a Build Artifact + uses: actions/upload-artifact@v4.6.0 + with: + name: checkstyle-report + path: build/reports/checkstyle/main/checkstyle.xml + + test: + + runs-on: ubuntu-latest + container: + image: maven:3.8.5-openjdk-17 + steps: + - + name: Checkout code + uses: actions/checkout@v4 + - + name: Run tests w/ Gradle + run: ./gradlew test + + build: + + runs-on: ubuntu-latest + container: + image: maven:3.8.5-openjdk-17 + steps: + - + name: Checkout code + uses: actions/checkout@v4 + + - + name: Run build w/o tests + run: ./gradlew build -x test + + docker: + + runs-on: ubuntu-latest + + steps: + - + name: Checkout the code from main branch + uses: actions/checkout@v4 + + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.9.0 + + - + name: Build and push Docker images + uses: docker/build-push-action@v6.13.0 + with: + push: true + tags: ${{ vars.DOCKERHUB_USERNAME }}/mr:${{ github.sha }} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/push-on-main.yml similarity index 91% rename from .github/workflows/build.yml rename to .github/workflows/push-on-main.yml index 6387cc3c9..dd14839f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/push-on-main.yml @@ -1,10 +1,11 @@ -name: Create and push docker image to Docker Hub. +name: Create and push docker image to Docker Hub on "push" event. on: push: branches: [ main ] - + jobs: + docker: runs-on: ubuntu-latest