api wiki alignment (#51) #3
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
| # | |
| # Twitter Backend - Moo: Twitter Clone Application Backend by Scaler | |
| # Copyright © 2021-2026 Subhrodip Mohanta (hello@subho.xyz) | |
| # | |
| name: Master CI & Distribution | |
| on: | |
| push: | |
| branches: [ master ] | |
| jobs: | |
| lint: | |
| name: Lint Check | |
| runs-on: ubuntu-slim | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Microsoft JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'microsoft' | |
| java-version: '21' | |
| cache: 'maven' | |
| - name: Cache Maven Wrapper | |
| uses: actions/cache@v4 | |
| with: | |
| path: .mvn/wrapper | |
| key: ${{ runner.os }}-maven-wrapper-${{ hashFiles('**/maven-wrapper.properties') }} | |
| - name: Cache Spotless Index | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.spotless | |
| key: ${{ runner.os }}-spotless-${{ hashFiles('**/pom.xml') }} | |
| - name: Run Spotless Check | |
| run: ./mvnw spotless:check | |
| build: | |
| name: Build & Archive | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Microsoft JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'microsoft' | |
| java-version: '21' | |
| cache: 'maven' | |
| - name: Cache Maven Wrapper | |
| uses: actions/cache@v4 | |
| with: | |
| path: .mvn/wrapper | |
| key: ${{ runner.os }}-maven-wrapper-${{ hashFiles('**/maven-wrapper.properties') }} | |
| - name: Build JAR | |
| run: ./mvnw -B clean package -DskipTests | |
| - name: Upload JAR artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: app-binary | |
| path: target/*.jar | |
| retention-days: 7 | |
| test: | |
| name: Run Tests | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Microsoft JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'microsoft' | |
| java-version: '21' | |
| cache: 'maven' | |
| - name: Cache Maven Wrapper | |
| uses: actions/cache@v4 | |
| with: | |
| path: .mvn/wrapper | |
| key: ${{ runner.os }}-maven-wrapper-${{ hashFiles('**/maven-wrapper.properties') }} | |
| - name: Run Maven Verify | |
| run: ./mvnw -B test | |
| security: | |
| name: Security Scan (CodeQL) | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| security-events: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Microsoft JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'microsoft' | |
| java-version: '21' | |
| cache: 'maven' | |
| - name: Cache Maven Wrapper | |
| uses: actions/cache@v4 | |
| with: | |
| path: .mvn/wrapper | |
| key: ${{ runner.os }}-maven-wrapper-${{ hashFiles('**/maven-wrapper.properties') }} | |
| - name: Initialize CodeQL | |
| uses: github/codeql-action/init@v4 | |
| with: | |
| languages: 'java' | |
| - name: Build for Scanning | |
| run: ./mvnw -B clean compile | |
| - name: Perform CodeQL Analysis | |
| uses: github/codeql-action/analyze@v4 | |
| distribution: | |
| name: Publish Images | |
| needs: [test, security] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Download JAR artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: app-binary | |
| path: target/ | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to DockerHub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract project version | |
| id: project | |
| run: echo "version=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT | |
| - name: Publish to Hub & GHCR | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: | | |
| subhrodip/twitter-backend-java:${{ steps.project.outputs.version }} | |
| subhrodip/twitter-backend-java:latest | |
| ghcr.io/${{ github.repository }}:${{ steps.project.outputs.version }} | |
| ghcr.io/${{ github.repository }}:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |