Skip to content

Commit 489ed9f

Browse files
authored
Update java-app.yml
1 parent 51a94bd commit 489ed9f

File tree

1 file changed

+58
-23
lines changed

1 file changed

+58
-23
lines changed

.github/workflows/java-app.yml

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,83 @@
1-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
31

4-
name: Java CI with Gradle
2+
# This workflow converts a Hugging Face model to ONNX format, builds a Java application with Gradle,
3+
# and generates and submits a dependency graph for the project.
4+
name: Java application
55

66
on:
77
push:
8-
branches: [ "main", "add-java-workflow" ]
8+
branches: ["main", "add-java-workflow"]
99
pull_request:
10-
branches: [ "main" ]
10+
branches: ["main"]
11+
12+
permissions:
13+
contents: read
1114

1215
jobs:
13-
build:
14-
16+
convert-model-to-onnx:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Python 3.10
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.10"
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -q transformers[onnx] transformers[sentencepiece] torch
29+
- name: Hugging Face Model to ONNX
30+
run: |
31+
# Convert Hugging Face Model to ONNX
32+
python -m transformers.onnx --opset 16 --atol 0.005 --feature=token-classification --model=xlm-roberta-large-finetuned-conll03-english onnx_model/
33+
34+
# Upload the ONNX model as an artifact
35+
- name: Upload ONNX model
36+
uses: actions/upload-artifact@v4.3.6
37+
with:
38+
# Artifact name
39+
name: onnx_model # default: artifact
40+
# Files to upload
41+
path: onnx_model/
42+
# Behavior if no files found: warn, error, ignore
43+
if-no-files-found: error
44+
# Expiration in days (1-90, 0 for default)
45+
retention-days: 0
46+
# Compression level (0-9, default: 6)
47+
compression-level: 7
48+
# Overwrite existing artifact (default: false)
49+
overwrite: true
50+
51+
# Build Java application with Gradle
52+
build-java:
1553
runs-on: ubuntu-latest
1654
permissions:
1755
contents: read
56+
needs: convert-model-to-onnx
1857

1958
steps:
2059
- uses: actions/checkout@v4
21-
60+
# Set up JDK 17
2261
- name: Set up JDK 17
2362
uses: actions/setup-java@v4
2463
with:
25-
java-version: '17'
26-
distribution: 'temurin'
64+
java-version: "17"
65+
distribution: "temurin"
2766

2867
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
2968
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
3069
- name: Setup Gradle
3170
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
32-
- name: Download a Build Artifact
71+
72+
- name: Download ONNX model from Artifact
3373
uses: actions/download-artifact@v4.1.8
3474
with:
35-
# Name of the artifact to download. If unspecified, all artifacts for the run are downloaded.
3675
name: onnx_model
37-
# Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE
38-
path: raw-files
39-
# The GitHub token used to authenticate with the GitHub API. This is required when downloading artifacts from a different repository or from a different workflow run. If this is not specified, the action will attempt to download artifacts from the current repository and the current workflow run.
40-
# github-token: ${{ secrets.GITHUB_TOKEN }} # optional
41-
# # The repository owner and the repository name joined together by "/". If github-token is specified, this is the repository that artifacts will be downloaded from.
42-
# repository: # optional, default is ${{ github.repository }}
43-
# The id of the workflow run where the desired download artifact was uploaded from. If github-token is specified, this is the run that artifacts will be downloaded from.
44-
run-id: python-app # optional, default is ${{ github.run_id }}
45-
76+
path: raw-files # path to download the artifact to
77+
run-id: ${{ github.run_id }}
78+
79+
- name: See artifact contents
80+
run: tree raw-files
4681

4782
# This job is responsible for generating and submitting a dependency graph for the project.
4883
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
@@ -58,8 +93,8 @@ jobs:
5893
- name: Set up JDK 17
5994
uses: actions/setup-java@v4
6095
with:
61-
java-version: '17'
62-
distribution: 'temurin'
96+
java-version: "17"
97+
distribution: "temurin"
6398

6499
- name: Generate and submit dependency graph
65100
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

0 commit comments

Comments
 (0)