Build #1673
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 | |
| on: | |
| push: | |
| branches: ["main", "dev"] | |
| pull_request: | |
| branches: ["main", "dev"] | |
| merge_group: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: SageSeekerSociety/cheese-backend-nt | |
| jobs: | |
| build-jar: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: "21" | |
| distribution: "zulu" | |
| cache: "maven" | |
| settings-path: ${{ github.workspace }} # location for the settings.xml file | |
| - name: Create .env file | |
| run: cp sample.env .env | |
| - name: Setup Services | |
| run: | | |
| docker compose -f docker-compose.yml up -d | |
| echo "Waiting for services to be ready..." | |
| timeout=180 | |
| elapsed=0 | |
| while [ $elapsed -lt $timeout ]; do | |
| if docker compose ps | grep -q "healthy"; then | |
| echo "All services are ready" | |
| break | |
| fi | |
| echo "Waiting for health check... ${elapsed}s/${timeout}s" | |
| sleep 10 | |
| elapsed=$((elapsed + 10)) | |
| done | |
| if [ $elapsed -ge $timeout ]; then | |
| echo "Services startup timeout!" | |
| docker compose logs | |
| exit 1 | |
| fi | |
| - name: Build with Maven | |
| env: | |
| KOTLIN_POST_PROCESS_FILE: python3 ${{ github.workspace }}/scripts/fix_kotlin_defaults.py | |
| run: ./mvnw install | |
| - name: Upload jar | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: jar | |
| path: target/*.jar | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: coverage | |
| path: target/site/jacoco | |
| build-docker: | |
| runs-on: ubuntu-latest | |
| needs: build-jar | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download jar artifact | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: jar | |
| path: ./artifacts | |
| - name: Set JAR_PATH | |
| run: | | |
| JAR_FILE=$(find ./artifacts -name "*.jar" | head -n 1) | |
| echo "JAR_PATH=$JAR_FILE" >> $GITHUB_ENV | |
| echo "Found JAR: $JAR_FILE" | |
| - name: Login to docker registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| JAR_PATH=${{ env.JAR_PATH }} | |
| build: # marks the end of the build process | |
| runs-on: ubuntu-latest | |
| needs: build-docker | |
| steps: | |
| - uses: actions/checkout@v6 |