|
| 1 | +name: Build and Push CI Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build and Test with Maven |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up JDK 8 |
| 20 | + uses: actions/setup-java@v4 |
| 21 | + with: |
| 22 | + distribution: 'temurin' |
| 23 | + java-version: '8' |
| 24 | + |
| 25 | + - name: Build with Maven |
| 26 | + run: mvn --batch-mode clean install |
| 27 | + |
| 28 | + - name: Upload Artifact codegen |
| 29 | + if: github.ref == 'refs/heads/master' || github.event.pull_request.base.ref == 'master' |
| 30 | + uses: actions/upload-artifact@v4 |
| 31 | + with: |
| 32 | + name: javatoavalla-1.0-SNAPSHOT-jar-with-dependencies.jar |
| 33 | + path: target/javatoavalla-1.0-SNAPSHOT-jar-with-dependencies.jar |
| 34 | + retention-days: 1 |
| 35 | + |
| 36 | + docker: |
| 37 | + name: Push Docker Image |
| 38 | + needs: build |
| 39 | + runs-on: ubuntu-latest |
| 40 | + if: github.ref == 'refs/heads/master' || github.event.pull_request.base.ref == 'master' |
| 41 | + steps: |
| 42 | + - name: Checkout repository |
| 43 | + uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Download artifact |
| 46 | + uses: actions/download-artifact@v4 |
| 47 | + with: |
| 48 | + name: javatoavalla-1.0-SNAPSHOT-jar-with-dependencies.jar |
| 49 | + path: ./target |
| 50 | + |
| 51 | + - name: Login to Docker Hub |
| 52 | + uses: docker/login-action@v3 |
| 53 | + with: |
| 54 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 55 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 56 | + |
| 57 | + - name: Build and push |
| 58 | + uses: docker/build-push-action@v6 |
| 59 | + with: |
| 60 | + context: . |
| 61 | + dockerfile: ./Dockerfile |
| 62 | + push: true |
| 63 | + tags: isaacmaffeis/javatoavalla:latest |
| 64 | + |
| 65 | + - name: Delete Artifact |
| 66 | + |
| 67 | + with: |
| 68 | + name: javatoavalla-1.0-SNAPSHOT-jar-with-dependencies.jar |
0 commit comments