Skip to content

Commit

Permalink
Set new java version from build argument
Browse files Browse the repository at this point in the history
  • Loading branch information
o-liver committed Jul 27, 2023
1 parent 545ca54 commit 7504443
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ jobs:
base-image-tag: [16-buster, 16-bullseye, 18-bullseye, 16-bookworm, 18-bookworm, 20-bookworm]
steps:
- uses: actions/checkout@master
- name: Determine Java version
id: java_version
run: |
if [[ "${{ matrix.base-image-tag }}" == *"-buster" ]] || [[ "${{ matrix.base-image-tag }}" == *"-bullseye" ]]; then
echo "::set-output name=version::11"
else
echo "::set-output name=version::17"
fi
- name: Test
run: |
chmod +x runTests.sh && ./runTests.sh ${{ matrix.base-image-tag }}
chmod +x runTests.sh && ./runTests.sh ${{ matrix.base-image-tag }} ${{ steps.java_version.outputs.version }}
- name: Build
run: |
docker build --build-arg=BASE_IMAGE_TAG=${{ matrix.base-image-tag }} --tag ppiper/node-browsers:${{ matrix.base-image-tag }} .
docker build --build-arg=BASE_IMAGE_TAG=${{ matrix.base-image-tag }} --build-arg=JAVA_VERSION=${{ steps.java_version.outputs.version }} --tag ppiper/node-browsers:${{ matrix.base-image-tag }} .
docker tag ppiper/node-browsers:${{ matrix.base-image-tag }} ghcr.io/sap/ppiper-node-browsers:${{ matrix.base-image-tag }}
- name: Tag latest image
if: ${{ matrix.base-image-tag == '18-bullseye' }}
if: ${{ matrix.base-image-tag == '20-bookworm' }}
run: |
docker tag ppiper/node-browsers:${{ matrix.base-image-tag }} ppiper/node-browsers:latest
docker tag ghcr.io/sap/ppiper-node-browsers:${{ matrix.base-image-tag }} ghcr.io/sap/ppiper-node-browsers:latest
Expand All @@ -35,7 +43,7 @@ jobs:
echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ secrets.CR_USER }} --password-stdin
docker push ppiper/node-browsers:${{ matrix.base-image-tag }}
docker push ghcr.io/sap/ppiper-node-browsers:${{ matrix.base-image-tag }}
if [ "${{ matrix.base-image-tag }}" == 18-bullseye ]; then
if [ "${{ matrix.base-image-tag }}" == 20-bookworm ]; then
docker push ppiper/node-browsers:latest
docker push ghcr.io/sap/ppiper-node-browsers:latest
fi
18 changes: 13 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ jobs:
base-image-tag: [16-buster, 16-bullseye, 18-bullseye, 16-bookworm, 18-bookworm, 20-bookworm]
steps:
- uses: actions/checkout@v1
- name: Determine Java version
id: java_version
run: |
if [[ "${{ matrix.base-image-tag }}" == *"-buster" ]] || [[ "${{ matrix.base-image-tag }}" == *"-bullseye" ]]; then
echo "::set-output name=version::11"
else
echo "::set-output name=version::17"
fi
- name: Test
run: |
chmod +x runTests.sh && ./runTests.sh ${{ matrix.base-image-tag }}
chmod +x runTests.sh && ./runTests.sh ${{ matrix.base-image-tag }} ${{ steps.java_version.outputs.version }}
- name: Prepare Release
run: |
CURRENT_VERSION_LONG=$(curl --silent "https://api.github.com/repos/SAP/devops-docker-node-browsers/releases" | jq -r '.[].tag_name' | head -n1)
Expand All @@ -36,19 +44,19 @@ jobs:
run: |
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USER }} --password-stdin
echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ secrets.CR_USER }} --password-stdin
docker build --build-arg=BASE_IMAGE_TAG=${{ matrix.base-image-tag }} --tag ppiper/node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }} .
docker build --build-arg=BASE_IMAGE_TAG=${{ matrix.base-image-tag }} --build-arg=JAVA_VERSION=${{ steps.java_version.outputs.version }} --tag ppiper/node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }} .
docker tag ppiper/node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }} ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }}
docker push ppiper/node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }}
docker push ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }}
- name: Tag and push node 18 image
if: ${{ matrix.base-image-tag == '18-bullseye' }}
- name: Tag and push node 20 image
if: ${{ matrix.base-image-tag == '20-bookworm' }}
run: |
docker tag ppiper/node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }} ppiper/node-browsers:${{ env.PIPER_version }}
docker tag ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}-${{ matrix.base-image-tag }} ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}
docker push ppiper/node-browsers:${{ env.PIPER_version }}
docker push ghcr.io/sap/ppiper-node-browsers:${{ env.PIPER_version }}
- uses: SAP/project-piper-action@master
if: ${{ matrix.base-image-tag == '18-bullseye' }}
if: ${{ matrix.base-image-tag == '20-bookworm' }}
with:
piper-version: latest
command: githubPublishRelease
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
ARG BASE_IMAGE_TAG
ARG JAVA_VERSION

FROM node:$BASE_IMAGE_TAG

RUN apt-get update && \
apt-get install -y chromium firefox-esr xvfb libxi6 libgbm1 libgconf-2-4 openjdk-11-jre && \
apt-get install -y chromium firefox-esr xvfb libxi6 libgbm1 libgconf-2-4 openjdk-${JAVA_VERSION}-jre && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/* && \
ln -s /usr/bin/chromium /usr/bin/google-chrome

Expand Down
3 changes: 2 additions & 1 deletion runTests.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash -ex

TAG=${1:-.}
JAVA_VERSION=${2}

echo Testing version $TAG

docker build --build-arg=BASE_IMAGE_TAG=${TAG} -t localhost:5000/ppiper/node-browsers:${TAG} .
docker build --build-arg=BASE_IMAGE_TAG=${TAG} --build-arg=JAVA_VERSION=${JAVA_VERSION} -t localhost:5000/ppiper/node-browsers:${TAG} .

docker run --rm localhost:5000/ppiper/node-browsers:${TAG} chromium --version
docker run --rm localhost:5000/ppiper/node-browsers:${TAG} firefox --version
Expand Down

0 comments on commit 7504443

Please sign in to comment.