Switch to Maven #236
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build JavaBot | |
| on: [push, pull_request, workflow_dispatch] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '25' | |
| cache: 'maven' | |
| distribution: 'temurin' | |
| - name: Build and run tests | |
| run: mvn verify | |
| nativetest: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up JDK 25 | |
| uses: graalvm/setup-graalvm@v1 | |
| with: | |
| java-version: '25' | |
| distribution: 'graalvm-community' | |
| cache: 'maven' | |
| - name: Run tests with native-image | |
| run: mvn test -PnativeTest | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: | |
| - build | |
| if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' }} | |
| concurrency: | |
| group: publish | |
| cancel-in-progress: true | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up JDK 25 | |
| uses: graalvm/setup-graalvm@v1 | |
| with: | |
| java-version: '25' | |
| distribution: 'graalvm-community' | |
| cache: 'maven' | |
| - name: Build native-image | |
| run: "mvn native:compile -Pnative -Pprod '-P!dev'" | |
| - name: Build Docker image | |
| run: docker build -t javabot . | |
| - name: Tag docker image | |
| run: | | |
| docker tag javabot ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}:${{ github.sha }} | |
| docker tag javabot ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}:latest | |
| env: | |
| dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| if: env.dockerhub_username != null | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| env: | |
| dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| if: env.dockerhub_username != null | |
| - name: Push to Docker Hub | |
| run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }} | |
| env: | |
| dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| if: env.dockerhub_username != null |