Skip to content

Commit e1585d4

Browse files
committed
Add workflow
1 parent 679c5a1 commit e1585d4

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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-oci-image-jvm-amd64:
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_amd64
28+
image_file: authorization_jvm_amd64.yaml
29+
runs_on: ubuntu-latest
30+
save-image-jvm-amd64:
31+
needs: build-oci-image-jvm-amd64
32+
uses: making/workflows/.github/workflows/save-images.yaml@main
33+
with:
34+
image_name: authorization_jvm_amd64
35+
image_file: authorization_jvm_amd64.yaml
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
runs_on:
21+
required: false
22+
type: string
23+
default: ubuntu-latest
24+
jobs:
25+
build:
26+
runs-on: ${{ inputs.runs_on }}
27+
permissions:
28+
contents: read
29+
packages: write
30+
steps:
31+
- uses: actions/checkout@v2
32+
- uses: graalvm/setup-graalvm@v1
33+
with:
34+
java-version: '21'
35+
distribution: graalvm
36+
cache: 'maven'
37+
- name: Set version
38+
run: |
39+
CURRENT_VERSION=$(./mvnw -f ${{ inputs.module }} help:evaluate -Dexpression=project.version -q -DforceStdout)
40+
NEW_VERSION=$(echo $CURRENT_VERSION | sed "s/-SNAPSHOT/.${GITHUB_SHA}/")
41+
./mvnw -f ${{ inputs.module }} versions:set -DnewVersion=${NEW_VERSION} -DgenerateBackupPoms=false --no-transfer-progress
42+
- name: build image (Paketo Buildpack)
43+
run: |
44+
OS_ARCH=$(./mvnw -f ${{ inputs.module }} help:evaluate -Dexpression=os.arch -q -DforceStdout)
45+
./mvnw -V -f ${{ inputs.module }} --no-transfer-progress spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=ghcr.io/${{ github.repository }}/${{ inputs.module }}:jvm_${OS_ARCH}_${GITHUB_SHA}
46+
- name: Login to GitHub Container Registry
47+
if: github.ref == inputs.target_ref
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
- name: docker push
54+
if: github.ref == inputs.target_ref
55+
run: |
56+
OS_ARCH=$(./mvnw -f ${{ inputs.module }} help:evaluate -Dexpression=os.arch -q -DforceStdout)
57+
docker push ghcr.io/${{ github.repository }}/${{ inputs.module }}:jvm_${OS_ARCH}_${GITHUB_SHA}
58+
docker tag ghcr.io/${{ github.repository }}/${{ inputs.module }}:jvm_${OS_ARCH}_${GITHUB_SHA} ghcr.io/${{ github.repository }}/${{ inputs.module }}:jvm_${OS_ARCH}
59+
docker push ghcr.io/${{ github.repository }}/${{ inputs.module }}:jvm_${OS_ARCH}
60+
- name: Generate digest
61+
if: github.ref == inputs.target_ref
62+
run: |
63+
OS_ARCH=$(./mvnw -f ${{ inputs.module }} help:evaluate -Dexpression=os.arch -q -DforceStdout)
64+
cat <<EOF > ${{ inputs.image_file }}
65+
image: $(docker inspect --format='{{index .RepoDigests 0}}' ghcr.io/${{ github.repository }}/${{ inputs.module }}:jvm_${OS_ARCH}_${GITHUB_SHA})
66+
git_revision: ${GITHUB_SHA}
67+
EOF
68+
- name: Upload artifact
69+
if: github.ref == inputs.target_ref
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: ${{ inputs.image_name }}
73+
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)