- Optimized recipe scraper #31
This file contains 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: FlavorMate server build workflow | |
on: | |
pull_request: | |
branches: [ main ] | |
paths: | |
- 'src/**' | |
- '.github/workflows/release-workflow.yaml' | |
- 'pom.xml' | |
push: | |
branches: [ main ] | |
paths: | |
- 'src/**' | |
- '.github/workflows/release-workflow.yaml' | |
- 'pom.xml' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
project-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml -DskipTests | |
- name: Cache JAR File | |
id: artifact-upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: flavormate-jar | |
path: target/flavormate-server.jar | |
retention-days: 1 | |
docker-build: | |
needs: | |
- project-build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
attestations: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Download JAR File | |
uses: actions/download-artifact@v4 | |
with: | |
name: flavormate-jar | |
path: target | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
flavor: | | |
latest=true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
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 | |
- name: Remove untagged images | |
uses: dataaxiom/ghcr-cleanup-action@v1 | |
with: | |
delete-untagged: true | |
token: ${{ secrets.GITHUB_TOKEN }} |