|
| 1 | +# This is a basic workflow to help you get started with Actions |
| 2 | + |
| 3 | +name: CI - Build and push Docker images - Quarkus Service |
| 4 | + |
| 5 | +# Controls when the action will run. Triggers the workflow on push or pull request |
| 6 | +# events but only for the master branch |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [ master ] |
| 10 | + |
| 11 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 12 | +jobs: |
| 13 | + # This workflow contains a single job called "build" |
| 14 | + build: |
| 15 | + if: contains(toJson(github), 'build quarkus-service') |
| 16 | + name: Build Jar/Docker Image and Publish to DockerHub |
| 17 | + |
| 18 | + # The type of runner that the job will run on |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 22 | + steps: |
| 23 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v2 |
| 26 | + |
| 27 | + # Set up JDK |
| 28 | + - name: JDK |
| 29 | + uses: actions/setup-java@v1 |
| 30 | + with: |
| 31 | + java-version: 17 |
| 32 | + |
| 33 | + - name: Set up QEMU |
| 34 | + uses: docker/setup-qemu-action@v1 |
| 35 | + |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v1 |
| 38 | + |
| 39 | + # Login to Dockerhub |
| 40 | + - name: Login to DockerHub |
| 41 | + uses: docker/login-action@v1 |
| 42 | + with: |
| 43 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 44 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 45 | + |
| 46 | + # Build Docker image using docker:build |
| 47 | + - name: Build Service using docker:build |
| 48 | + run: | |
| 49 | + mvn clean package -DskipTests -q -pl quarkus-service -am -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn |
| 50 | +
|
| 51 | + - name: Build and push |
| 52 | + id: docker_build |
| 53 | + uses: docker/build-push-action@v2 |
| 54 | + with: |
| 55 | + context: ./quarkus-service/target/docker/quarkus-service/build |
| 56 | + file: ./quarkus-service/target/docker/quarkus-service/build/Dockerfile |
| 57 | + platforms: linux/amd64,linux/arm64 |
| 58 | + push: true |
| 59 | + tags: fielcapao/microservices-design-patterns-quarkus-service:latest |
| 60 | + |
| 61 | + - name: Image digest |
| 62 | + run: echo ${{ steps.docker_build.outputs.digest }} |
0 commit comments