name: CI on: push: branches: - "main" tags: - '*' pull_request: branches: - "main" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: package: name: Package runs-on: ubuntu-24.04 timeout-minutes: 15 steps: - name: Checkout uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up JDK uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5 with: distribution: 'temurin' java-version: '25' cache: 'maven' - name: Build package run: | chmod +x ./mvnw ./mvnw --batch-mode --update-snapshots verify - name: Upload test reports if: always() uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: junit-reports path: | **/target/*-reports/TEST-*.xml if-no-files-found: ignore - name: Upload Maven artifacts uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: maven-artifacts path: | target/netneutrality.jar startup.sh if-no-files-found: error maven-publish: name: Publish Maven Package runs-on: ubuntu-24.04 timeout-minutes: 15 needs: package if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} steps: - name: Checkout uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Set up JDK uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5 with: distribution: 'temurin' java-version: '25' cache: 'maven' server-id: gitea server-username: REGISTRY_USER server-password: REGISTRY_PASSWORD - name: Publish Maven package run: | chmod +x ./mvnw ./mvnw --batch-mode deploy -DskipTests env: REGISTRY_USER: ${{ secrets.REGISTRY_USER }} REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} docker: name: Docker Build and Push runs-on: ubuntu-24.04 timeout-minutes: 15 needs: package if: ${{ github.event_name == 'push' }} permissions: contents: read packages: write steps: - name: Checkout uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - name: Download build artifacts uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: maven-artifacts path: . - name: Compute Docker tags id: meta shell: bash run: | REGISTRY="${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/netneutrality" if [[ "$GITHUB_REF" == refs/tags/* ]]; then ver="${GITHUB_REF_NAME#v}" echo "tags=${REGISTRY}:${ver},${REGISTRY}:latest" >> "$GITHUB_OUTPUT" else echo "tags=${REGISTRY}:main" >> "$GITHUB_OUTPUT" fi - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 - name: Log in to registry uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4 with: registry: ${{ secrets.REGISTRY_URL }} username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} - name: Build and push uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7 with: context: . file: ./Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} cache-from: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/netneutrality:buildcache cache-to: type=registry,ref=${{ secrets.REGISTRY_URL }}/${{ secrets.REGISTRY_USER }}/netneutrality:buildcache,mode=max