Skip to content

Update java-app.yml

Update java-app.yml #9

Workflow file for this run

# This workflow converts a Hugging Face model to ONNX format, builds a Java application with Gradle,
# and generates and submits a dependency graph for the project.
name: Java application
on:
push:
branches: ["main", "add-java-workflow"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
convert-model-to-onnx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -q transformers[onnx] transformers[sentencepiece] torch
- name: Hugging Face Model to ONNX
run: |
# Convert Hugging Face Model to ONNX
python -m transformers.onnx --opset 16 --atol 0.005 --feature=token-classification --model=xlm-roberta-large-finetuned-conll03-english onnx_model/
# Upload the ONNX model as an artifact
- name: Upload ONNX model
uses: actions/[email protected]
with:
# Artifact name
name: onnx_model # default: artifact
# Files to upload
path: onnx_model/
# Behavior if no files found: warn, error, ignore
if-no-files-found: error
# Expiration in days (1-90, 0 for default)
retention-days: 0
# Compression level (0-9, default: 6)
compression-level: 7
# Overwrite existing artifact (default: false)
overwrite: true
# Build Java application with Gradle
build-java:
runs-on: ubuntu-latest
permissions:
contents: read
needs: convert-model-to-onnx
steps:
- uses: actions/checkout@v4
# Set up JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
- name: Download ONNX model from Artifact
uses: actions/[email protected]
with:
name: onnx_model
path: raw-files # path to download the artifact to
run-id: ${{ github.run_id }}
- name: See artifact contents
run: tree raw-files
# This job is responsible for generating and submitting a dependency graph for the project.
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
dependency-submission:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0