Skip to content

Commit fcda6c1

Browse files
authored
OpenJDK Image (#1001)
1 parent 5aea5b0 commit fcda6c1

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: "Build OBaaS Base Image"
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
workflow_dispatch:
6+
env:
7+
dst_img: openjdk-image-obaas
8+
description: "OpenJDK OBaaS Image."
9+
jobs:
10+
obaas-image:
11+
strategy:
12+
matrix:
13+
base_version: [17, 21]
14+
runs-on: ubuntu-latest
15+
permissions:
16+
packages: write
17+
contents: read
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
sparse-checkout: .github
22+
23+
- name: Login to GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Get latest Image Software Digest
31+
run: |
32+
latest_digest=$(docker run --rm --entrypoint cat ghcr.io/${{ github.repository_owner }}/${{ env.dst_img }}:${{ matrix.base_version }} /image_digest)
33+
echo "Current Digest: $latest_digest"
34+
echo "latest_digest=$latest_digest" >> $GITHUB_ENV
35+
continue-on-error: true
36+
37+
- name: Create New Image
38+
if: env.latest_digest == ''
39+
uses: ./.github/actions/process-image
40+
with:
41+
src_image: container-registry.oracle.com/java/openjdk:${{ matrix.base_version }}
42+
dst_image: ghcr.io/${{ github.repository_owner }}/${{ env.dst_img }}:${{ matrix.base_version }}
43+
description: ${{ env.description }}
44+
push: true
45+
46+
- name: Run Trivy Vulnerability Scanner
47+
id: trivy_scan
48+
if: env.latest_digest != ''
49+
env:
50+
TRIVY_DEFAULT: "--format table --ignore-unfixed --exit-code 1"
51+
TRIVY_SCAN: "--severity CRITICAL,HIGH --vuln-type os,library"
52+
run: >
53+
docker run --rm ghcr.io/aquasecurity/trivy:latest image $TRIVY_DEFAULT $TRIVY_SCAN
54+
--username ${{ github.actor }}
55+
--password ${{ secrets.GITHUB_TOKEN }}
56+
ghcr.io/${{ github.repository_owner }}/${{ env.dst_img }}:${{ matrix.base_version }}
57+
continue-on-error: true
58+
59+
- name: Update Existing Image
60+
id: update_image
61+
if: env.latest_digest != '' && steps.trivy_scan.outcome == 'failure'
62+
uses: ./.github/actions/process-image
63+
with:
64+
src_image: ghcr.io/${{ github.repository_owner }}/${{ env.dst_img }}:${{ matrix.base_version }}
65+
dst_image: ghcr.io/${{ github.repository_owner }}/${{ env.dst_img }}:${{ matrix.base_version }}
66+
description: ${{ env.description }}
67+
push: false
68+
69+
- name: Get newest Image Software Digest
70+
id: get_newest_digest
71+
if: steps.update_image.outcome != 'skipped'
72+
run: |
73+
newest_digest=$(docker run --rm --entrypoint cat ghcr.io/${{ github.repository_owner }}/${{ env.dst_img }}:${{ matrix.base_version }} /image_digest)
74+
echo "New Digest: $newest_digest"
75+
echo "newest_digest=$newest_digest" >> $GITHUB_ENV
76+
77+
- name: Push Updated Image
78+
if: steps.get_newest_digest.outcome != 'skipped' && env.latest_digest != env.newest_digest
79+
uses: ./.github/actions/process-image
80+
with:
81+
src_image: ghcr.io/${{ github.repository_owner }}/${{ env.dst_img }}:${{ matrix.base_version }}
82+
dst_image: ghcr.io/${{ github.repository_owner }}/${{ env.dst_img }}:${{ matrix.base_version }}
83+
description: ${{ env.description }}
84+
push: true

0 commit comments

Comments
 (0)