Skip to content

Commit 4443589

Browse files
committed
Add workflow
1 parent 679c5a1 commit 4443589

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Authorization
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- authorization/src/**
8+
- authorization/pom.xml
9+
- .github/workflows/*
10+
pull_request:
11+
branches:
12+
- main
13+
paths:
14+
- authorization/src/**
15+
- authorization/pom.xml
16+
- .github/workflows/*
17+
jobs:
18+
unit-test:
19+
uses: making/oauth2-sso-demo/.github/workflows/unit-test.yaml@main
20+
with:
21+
module: authorization
22+
build-image-jvm:
23+
needs: unit-test
24+
uses: making/oauth2-sso-demo/.github/workflows/build-oci-image-jvm.yaml@main
25+
with:
26+
module: authorization
27+
image_name: authorization_jvm
28+
image_file: authorization_jvm.yaml
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build OCI Image (JVM)
2+
on:
3+
workflow_call:
4+
inputs:
5+
module:
6+
required: true
7+
type: string
8+
image_name:
9+
required: false
10+
type: string
11+
default: image
12+
image_file:
13+
required: false
14+
type: string
15+
default: image.yaml
16+
target_ref:
17+
required: false
18+
type: string
19+
default: 'refs/heads/main'
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: graalvm/setup-graalvm@v1
29+
with:
30+
java-version: '21'
31+
distribution: graalvm
32+
cache: 'maven'
33+
- name: Set version
34+
run: |
35+
CURRENT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
36+
NEW_VERSION=$(echo $CURRENT_VERSION | sed "s/-SNAPSHOT/.${GITHUB_SHA}/")
37+
./mvnw -f ${{ inputs.module }} versions:set -DnewVersion=${NEW_VERSION} -DgenerateBackupPoms=false --no-transfer-progress
38+
- name: build image (Paketo Buildpack)
39+
run: ./mvnw -V -f ${{ inputs.module }} --no-transfer-progress spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=ghcr.io/${{ github.repository }}:jvm_${GITHUB_SHA}
40+
- name: Login to GitHub Container Registry
41+
if: github.ref == inputs.target_ref
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ghcr.io
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
- name: docker push
48+
if: github.ref == inputs.target_ref
49+
run: |
50+
docker push ghcr.io/${{ github.repository }}:jvm_${GITHUB_SHA}
51+
docker tag ghcr.io/${{ github.repository }}:jvm_${GITHUB_SHA} ghcr.io/${{ github.repository }}:jvm
52+
docker push ghcr.io/${{ github.repository }}:jvm
53+
- name: Generate digest
54+
if: github.ref == inputs.target_ref
55+
run: |
56+
cat <<EOF > ${{ inputs.image_file }}
57+
image: $(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ github.repository }}:jvm_${GITHUB_SHA})
58+
git_revision: ${GITHUB_SHA}
59+
EOF
60+
- name: Upload artifact
61+
if: github.ref == inputs.target_ref
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: ${{ inputs.image_name }}
65+
path: ${{ inputs.image_file }}

.github/workflows/unit-test.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Unit Test
2+
on:
3+
workflow_call:
4+
inputs:
5+
module:
6+
required: true
7+
type: string
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: graalvm/setup-graalvm@v1
17+
with:
18+
java-version: '21'
19+
distribution: graalvm
20+
cache: 'maven'
21+
- name: unit test
22+
run: ./mvnw -V -f ${{ inputs.module }} clean test --no-transfer-progress

0 commit comments

Comments
 (0)