Skip to content

fix: update build-runner.yml to reference correct JDK_DIR for version… #11

fix: update build-runner.yml to reference correct JDK_DIR for version…

fix: update build-runner.yml to reference correct JDK_DIR for version… #11

Workflow file for this run

name: Build web-tools Images
on:
push:
branches:
- master
paths:
- 'openjdk*/*'
- '.github/workflows/build-runner.yml'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
jdk_version: [8, 11, 17, 21]
node_version: [18, 20, 22]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Docker login
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo $DOCKER_HUB_PASSWORD | docker login --username $DOCKER_HUB_USERNAME --password-stdin
echo $GITHUB_TOKEN | docker login ghcr.io --username $GITHUB_ACTOR --password-stdin
- name: Set Environment Variables
id: vars
run: |
JDK_DIR=openjdk${{ matrix.jdk_version }}-alpine
NODE_MAJOR_VERSION=${{ matrix.node_version }}
NODE_VERSION="$(awk -F '[=]' '/NODE_${{ matrix.node_version }}_VERSION/ {print $2}' node_version.env)"
if [[ -f ${JDK_DIR}/Dockerfile ]]; then
OPENJDK_VERSION="$(awk -F '[=]' '/ENV OPENJDK_VERSION/ {print $2}' ${JDK_DIR}/Dockerfile)"
echo $NODE_VERSION > ${JDK_DIR}/version.txt
echo $OPENJDK_VERSION > ${JDK_DIR}/openjdk_version.txt
else
NODE_VERSION=$(cat ${JDK_DIR}/version.txt)
OPENJDK_VERSION=$(cat ${JDK_DIR}/openjdk_version.txt)
fi
echo "JDK_DIR=${JDK_DIR}" >> $GITHUB_ENV
echo "NODE_VERSION=${NODE_VERSION}" >> $GITHUB_ENV
echo "OPENJDK_VERSION=${OPENJDK_VERSION}" >> $GITHUB_ENV
echo "NODE_MAJOR_VERSION=${NODE_MAJOR_VERSION}" >> $GITHUB_ENV
- name: Build Docker Image
run: |
IMAGE_NAME=ringcentral/web-tools
sed -i "s/\$NODE_VERSION/$NODE_VERSION/g" ${JDK_DIR}/Dockerfile
docker build --tag ${IMAGE_NAME} --file ${JDK_DIR}/Dockerfile .
- name: Tag and Push Docker Images
run: |
IMAGE_NAME=ringcentral/web-tools
GH_DOCKER_PKG_IMAGE_NAME=ghcr.io/ringcentral-docker/web-tools/web-tools
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:node${NODE_MAJOR_VERSION}-openjdk${OPENJDK_VERSION}-alpine"
docker push "${IMAGE_NAME}:node${NODE_MAJOR_VERSION}-openjdk${OPENJDK_VERSION}-alpine"
docker tag "${IMAGE_NAME}" "${GH_DOCKER_PKG_IMAGE_NAME}:node${NODE_MAJOR_VERSION}-openjdk${OPENJDK_VERSION}-alpine"
docker push "${GH_DOCKER_PKG_IMAGE_NAME}:node${NODE_MAJOR_VERSION}-openjdk${OPENJDK_VERSION}-alpine"
if [ "${{ matrix.jdk_version }}" -eq 21 ]; then
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${NODE_VERSION}-alpine"
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${NODE_MAJOR_VERSION}-alpine"
docker push "${IMAGE_NAME}:${NODE_VERSION}-alpine"
docker push "${IMAGE_NAME}:${NODE_MAJOR_VERSION}-alpine"
docker tag "${IMAGE_NAME}" "${GH_DOCKER_PKG_IMAGE_NAME}:${NODE_VERSION}-alpine"
docker tag "${IMAGE_NAME}" "${GH_DOCKER_PKG_IMAGE_NAME}:${NODE_MAJOR_VERSION}-alpine"
docker push "${GH_DOCKER_PKG_IMAGE_NAME}:${NODE_VERSION}-alpine"
docker push "${GH_DOCKER_PKG_IMAGE_NAME}:${NODE_MAJOR_VERSION}-alpine"
if [ "${{ matrix.node_version }}" -eq 22 ]; then
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:latest"
docker push "${IMAGE_NAME}:latest"
docker tag "${IMAGE_NAME}" "${GH_DOCKER_PKG_IMAGE_NAME}:latest"
docker push "${GH_DOCKER_PKG_IMAGE_NAME}:latest"
fi
fi
- name: Generate README Update
run: |
IMAGE_NAME=ringcentral/web-tools
GH_DOCKER_PKG_IMAGE_NAME=ghcr.io/ringcentral-docker/web-tools/web-tools
if [ "${{ matrix.node_version }}" -eq 22 ]; then
NEW_ENTRY="| JDK${{ matrix.jdk_version }} | ${NODE_DIR} | \`${IMAGE_NAME}:${NODE_VERSION}-alpine\` | \`${GH_DOCKER_PKG_IMAGE_NAME}:node${NODE_MAJOR_VERSION}-openjdk${OPENJDK_VERSION}-alpine\` |"
echo "${NEW_ENTRY}" > readme_updates_${{ matrix.jdk_version }}.txt
fi
- name: Upload README Update
uses: actions/upload-artifact@v4
with:
name: readme-updates-${{ matrix.jdk_version }}
path: readme_updates_${{ matrix.jdk_version }}.txt
update-readme:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download README Updates
uses: actions/download-artifact@v4
with:
name: readme-updates-8
path: ./readme-updates
- name: Download README Updates
uses: actions/download-artifact@v4
with:
name: readme-updates-11
path: ./readme-updates
- name: Download README Updates
uses: actions/download-artifact@v4
with:
name: readme-updates-17
path: ./readme-updates
- name: Download README Updates
uses: actions/download-artifact@v4
with:
name: readme-updates-21
path: ./readme-updates
- name: Initialize README
run: |
echo "| JDK Version | Version | Docker Hub | GitHub Package |" > README.md
echo "|-------------|---------|------------|----------------|" >> README.md
- name: Update README
run: |
for file in ./readme-updates/readme_updates_*.txt; do
while IFS= read -r line; do
JDK_VERSION=$(echo $line | cut -d' ' -f2)
if grep -q "JDK${JDK_VERSION}" README.md; then
sed -i "/JDK${JDK_VERSION}/c\\$line" README.md
else
echo "$line" >> README.md
fi
done < "$file"
done
- name: Commit README Update
run: |
git config --global user.name 'john.lin'
git config --global user.email '[email protected]'
git add README.md
git commit -m "Update README with Docker image info"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}