diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 000000000..16da83e54 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,51 @@ +name: CI/CD pipeline for successful merge +on: + workflow_dispatch: + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup java + uses: actions/setup-java@v4 + with: + java-version: '21' + cache: 'maven' + distribution: 'corretto' + + + - name: Maven install dependencies + run: ./mvnw clean install -Dmaven.test.skip=true + + docker: + if: ${{ github.event.pull_request.merged }} + runs-on: ubuntu-latest + needs: [build, test] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Docker Build + uses: docker/build-push-action@v6 + with: + push: false + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/apiprotector:$${{ github.sha }} + + - name: Docker Push + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/apiprotector:$${{ github.sha }} diff --git a/pom.xml b/pom.xml index 1fc18f0e7..ae09aae0b 100644 --- a/pom.xml +++ b/pom.xml @@ -165,6 +165,11 @@ spring-boot-docker-compose test + + org.mockito + mockito-core + test + org.testcontainers junit-jupiter @@ -329,11 +334,6 @@ - - - org.cyclonedx - cyclonedx-maven-plugin -