Update message editing logic to fix some bugs and clarify bot setup i… #24
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: Main Branch Workflow | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-jars: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'corretto' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Build with Gradle Wrapper | |
| run: ./gradlew build | |
| - name: Extract project name from Gradle | |
| run: | | |
| PROJECT_NAME=$(./gradlew -q printProjectName) | |
| echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV | |
| - name: Extract version from Gradle | |
| run: | | |
| VERSION=$(./gradlew -q printProjectVersion) | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| - name: Upload jars | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.PROJECT_NAME }}-${{ env.VERSION }}-jars | |
| path: build/libs/*.jar | |
| build-and-push-docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write | |
| id-token: write | |
| attestations: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from file | |
| run: | | |
| VERSION=$(./gradlew -q printProjectVersion) | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| - name: Change wrapper permissions | |
| run: chmod +x ./gradlew | |
| - name: Build and push Docker image | |
| id: push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Generate artifact attestation | |
| uses: actions/attest-build-provenance@v1 | |
| with: | |
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
| subject-digest: ${{ steps.push.outputs.digest }} | |
| push-to-registry: true | |
| build-git-badges: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Calculate Lines of Code | |
| id: loc | |
| uses: PavanMudigonda/[email protected] | |
| with: | |
| include_ext: "kt,java" | |
| - name: Add Lines of Code Summary | |
| run: echo "${{ steps.loc.outputs.lines-of-code-summary }}" >> $GITHUB_STEP_SUMMARY | |
| - name: Output git info | |
| id: git_info | |
| run: | | |
| function format_size { echo $(numfmt --to iec --suffix B $1); } | |
| function format_number { LC_ALL=en_US.UTF-8 printf "%'d\n" $1; } | |
| echo "file_count=$(format_number $(git ls-files | wc -l))" >> $GITHUB_OUTPUT | |
| echo "lines_of_code=${{ steps.loc.outputs.total_lines_int }}" >> $GITHUB_OUTPUT | |
| git gc | |
| echo "size=$(format_size $(($(git count-objects -v | grep 'size-pack: ' | sed 's/size-pack: //g' | tr -d '\n') * 1024)))" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Build-A-Badge | |
| uses: peterrhodesdev/[email protected] | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| filename: | | |
| ( | |
| "internal-git-size" | |
| "internal-git-file-count" | |
| "internal-git-lines-of-code" | |
| ) | |
| label: ("size" "files" "lines-of-code") | |
| message: | | |
| ( | |
| "${{ steps.git_info.outputs.size }}" | |
| "${{ steps.git_info.outputs.file_count }}" | |
| "${{ steps.git_info.outputs.lines_of_code }}" | |
| ) | |
| namedLogo: ("git" "git" "git") | |
| color: ("f1502f" "f1502f" "f1502f") |