Skip to content

Commit b711331

Browse files
committed
use build workflow
1 parent 99172b4 commit b711331

File tree

2 files changed

+9
-76
lines changed

2 files changed

+9
-76
lines changed

.github/workflows/reusable__build.yml

+5-23
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,7 @@ on:
1212
type: string
1313
description: 'The full Docker image tag to build (e.g., myrepo/myapp:1.2.3-abcdef).'
1414
required: true
15-
JAVA_VERSION:
16-
type: string
17-
description: 'Java version for build.'
18-
required: true
19-
NODE_VERSION:
20-
type: string
21-
description: 'Node.js version for build.'
22-
required: true
23-
24-
outputs:
25-
IMAGE_ARTIFACT_NAME:
26-
description: "The name of the uploaded Docker image artifact."
27-
# Construct a unique name based on the commit hash for consistency
28-
value: okr-image-${{ inputs.COMMIT_HASH }}
2915

30-
# No secrets typically needed just for building
3116

3217
jobs:
3318
build:
@@ -36,9 +21,6 @@ jobs:
3621
permissions:
3722
contents: read
3823
packages: read # If Maven/NPM downloads packages from GHCR
39-
outputs:
40-
# Expose the artifact name calculated in the workflow definition's outputs
41-
IMAGE_ARTIFACT_NAME: ${{ steps.set_artifact_name.outputs.name }}
4224
steps:
4325
- name: Set artifact name # Make output accessible to subsequent steps
4426
id: set_artifact_name
@@ -49,16 +31,16 @@ jobs:
4931
with:
5032
ref: ${{ inputs.COMMIT_HASH }} # Checkout the exact commit
5133

52-
- name: Set up JDK ${{ inputs.JAVA_VERSION }}
34+
- name: Set up JDK ${{ vars.JAVA_VERSION }}
5335
uses: actions/setup-java@v4
5436
with:
55-
java-version: ${{ inputs.JAVA_VERSION }}
37+
java-version: ${{ vars.JAVA_VERSION }}
5638
distribution: 'temurin'
5739

58-
- name: Set up node ${{ inputs.NODE_VERSION }}
40+
- name: Set up node ${{ vars.NODE_VERSION }}
5941
uses: actions/setup-node@v4
6042
with:
61-
node-version: ${{ inputs.NODE_VERSION }}
43+
node-version: ${{ vars.NODE_VERSION }}
6244

6345
- name: Install Frontend Dependencies
6446
run: cd ./frontend && npm ci
@@ -86,6 +68,6 @@ jobs:
8668
- name: Upload artifact (Docker image tarball)
8769
uses: actions/upload-artifact@v4
8870
with:
89-
name: ${{ steps.set_artifact_name.outputs.name }} # Use consistent name
71+
name: okr-image
9072
path: /tmp/okr-docker-image.tar
9173
retention-days: 1 # Keep artifact only briefly needed for next steps

.github/workflows/test-action.yml

+4-53
Original file line numberDiff line numberDiff line change
@@ -61,59 +61,10 @@ jobs:
6161
build-docker-image:
6262
# Update dependency: now needs 'versioning' instead of 'read-version'
6363
needs: [versioning]
64-
runs-on: ubuntu-24.04
65-
env: # Define BRANCH_NAME if needed within this job's steps
66-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
67-
steps:
68-
- uses: actions/checkout@v4
69-
with:
70-
# Checkout the branch head. Assumes 'versioning' pushed updates if needed.
71-
ref: ${{ env.BRANCH_NAME }}
72-
73-
- name: Set up JDK ${{vars.JAVA_VERSION}}
74-
uses: actions/setup-java@v4
75-
with:
76-
java-version: ${{vars.JAVA_VERSION}}
77-
distribution: 'adopt'
78-
79-
- name: Set up node ${{vars.NODE_VERSION}}
80-
uses: actions/setup-node@v4
81-
with:
82-
node-version: ${{vars.NODE_VERSION}}
83-
84-
- name: Install Dependencies
85-
run: cd ./frontend && npm ci
86-
87-
- name: Build frontend with Angular
88-
run: cd ./frontend && npm run build
89-
90-
- name: Build backend with Maven
91-
run: mvn -B clean package --file pom.xml -P build-for-docker
92-
93-
- name: Set up Docker Buildx
94-
uses: docker/setup-buildx-action@v3
95-
96-
- name: Build the docker image
97-
uses: docker/build-push-action@v6
98-
with:
99-
context: .
100-
file: docker/Dockerfile
101-
# Use output from the 'versioning' job
102-
tags: ${{ needs.versioning.outputs.IMAGE_TAG }}
103-
load: true
104-
push: false
105-
outputs: type=docker,dest=${{ runner.temp }}/okr-docker-image.tar
106-
107-
- name: Upload artifact
108-
uses: actions/upload-artifact@v4
109-
with:
110-
name: okr-image
111-
path: ${{ runner.temp }}/okr-docker-image.tar
112-
113-
- name: print imagetags
114-
run: echo ${{ needs.versioning.outputs.IMAGE_TAG }}
115-
- run: echo "${{ github.run_id }}"
116-
- run: echo "$(ls -la /tmp/)"
64+
uses: ./.github/workflows/reusable__build.yml
65+
with:
66+
COMMIT_HASH: ${{ github.head_ref || github.ref_name }}
67+
FULL_IMAGE_TAG: ${{needs.versioning.outputs.IMAGE_TAG}} # Use the output from the versioning job.
11768

11869

11970

0 commit comments

Comments
 (0)