From 52c48cd8b96250f209b6be1a3708ff5f51f7887b Mon Sep 17 00:00:00 2001 From: Antonio Musarra Date: Sun, 21 Apr 2024 22:25:34 +0200 Subject: [PATCH] Added GitHub Action to publish NativeImage on DockerHub --- .github/workflows/docker_publish.yml | 2 +- .../workflows/docker_publish_native_amd64.yml | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker_publish_native_amd64.yml diff --git a/.github/workflows/docker_publish.yml b/.github/workflows/docker_publish.yml index 913aaee..7921fde 100644 --- a/.github/workflows/docker_publish.yml +++ b/.github/workflows/docker_publish.yml @@ -1,4 +1,4 @@ -# CI with maven build and scan +# CI Docker build with maven build name: CI docker build on: diff --git a/.github/workflows/docker_publish_native_amd64.yml b/.github/workflows/docker_publish_native_amd64.yml new file mode 100644 index 0000000..0591ea1 --- /dev/null +++ b/.github/workflows/docker_publish_native_amd64.yml @@ -0,0 +1,63 @@ +# CI Docker build with maven build and native image build +name: CI docker build native amd64 + +on: + # Trigger analysis when pushing in master or pull requests, and when creating + # a pull request. + push: + branches: + - main + release: + types: [ published ] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@main + with: + # Shallow clones should be disabled for a better relevancy of analysis + fetch-depth: 0 + - name: Get repo name + run: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d '/' -f 2)" >> $GITHUB_ENV + - name: Echo ref name trigger + run: echo ${{ github.ref_name }} + + - uses: graalvm/setup-graalvm@main + with: + java-version: '22-ea' + distribution: 'graalvm' + github-token: ${{ secrets.TOKEN_GITHUB }} + native-image-job-reports: 'true' + + - name: Cache Maven packages + uses: actions/cache@main + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Build and analyze + run: mvn install -Dnative -Dquarkus.native.container-build=true + + - name: Set up QEMU + uses: docker/setup-qemu-action@master + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@master + + - name: Login to Docker Hub + uses: docker/login-action@master + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@master + with: + context: . + file: src/main/docker/Dockerfile.native-micro + platforms: linux/amd64 + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/${{ env.REPO_NAME }}:${{ github.ref_name }}-amd64native,${{ secrets.DOCKER_USERNAME }}/${{ env.REPO_NAME }}:latest-amd64native \ No newline at end of file