fix error #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build OpenJDK Images | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- 'jdk*/*' | |
- '.github/workflows/build-jdk.yml' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
jdk_version: [8, 11, 17, 21] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Docker login | |
env: | |
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | |
DOCKER_HUB_PASSWORD: ${{ secrets.DOOLDOCKER_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 docker.pkg.github.com --username $GITHUB_ACTOR --password-stdin | |
- name: Set Environment Variables | |
run: | | |
JDK_DIR=jdk${{ matrix.jdk_version }} | |
if [[ -f ${JDK_DIR}/Dockerfile ]]; then | |
VERSION=$(awk -F= '/JAVA_VERSION=/ {print $2}' ${JDK_DIR}/Dockerfile | cut -d " " -f 1) | |
DETAIL_VERSION=$(awk -F= '/JAVA_DETAIL_VERSION=/ {print $2}' ${JDK_DIR}/Dockerfile | cut -d " " -f 1) | |
echo $VERSION > ${JDK_DIR}/version.txt | |
echo $DETAIL_VERSION > ${JDK_DIR}/detail_version.txt | |
else | |
VERSION=$(cat ${JDK_DIR}/version.txt) | |
DETAIL_VERSION=$(cat ${JDK_DIR}/detail_version.txt) | |
fi | |
echo "JDK_DIR=${JDK_DIR}" >> $GITHUB_ENV | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
echo "DETAIL_VERSION=${DETAIL_VERSION}" >> $GITHUB_ENV | |
- name: Build Docker Image | |
run: | | |
IMAGE_NAME=ringcentral/jdk | |
docker build --tag ${IMAGE_NAME} --file ${JDK_DIR}/Dockerfile . | |
- name: Tag and Push Docker Images | |
run: | | |
IMAGE_NAME=ringcentral/jdk | |
GH_DOCKER_PKG_IMAGE_NAME=docker.pkg.github.com/ringcentral-docker/jdk/jdk | |
BASE_IMAGE="alpine" | |
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${VERSION}" | |
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${VERSION}-${BASE_IMAGE}" | |
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${DETAIL_VERSION}" | |
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${DETAIL_VERSION}-${BASE_IMAGE}" | |
docker push "${IMAGE_NAME}:${DETAIL_VERSION}-${BASE_IMAGE}" | |
docker push "${IMAGE_NAME}:${DETAIL_VERSION}" | |
docker push "${IMAGE_NAME}:${VERSION}-${BASE_IMAGE}" | |
docker push "${IMAGE_NAME}:${VERSION}" | |
docker tag "${IMAGE_NAME}" "${GH_DOCKER_PKG_IMAGE_NAME}:${VERSION}" | |
docker tag "${IMAGE_NAME}" "${GH_DOCKER_PKG_IMAGE_NAME}:${VERSION}-${BASE_IMAGE}" | |
docker tag "${IMAGE_NAME}" "${GH_DOCKER_PKG_IMAGE_NAME}:${DETAIL_VERSION}" | |
docker tag "${IMAGE_NAME}" "${GH_DOCKER_PKG_IMAGE_NAME}:${DETAIL_VERSION}-${BASE_IMAGE}" | |
docker push "${GH_DOCKER_PKG_IMAGE_NAME}:${DETAIL_VERSION}-${BASE_IMAGE}" | |
docker push "${GH_DOCKER_PKG_IMAGE_NAME}:${DETAIL_VERSION}" | |
docker push "${GH_DOCKER_PKG_IMAGE_NAME}:${VERSION}-${BASE_IMAGE}" | |
docker push "${GH_DOCKER_PKG_IMAGE_NAME}:${VERSION}" | |
if [ "${{ matrix.jdk_version }}" -eq 17 ]; 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 | |
- name: Generate README Update | |
run: | | |
BASE_IMAGE="alpine" | |
IMAGE_NAME=ringcentral/jdk | |
GH_DOCKER_PKG_IMAGE_NAME=docker.pkg.github.com/ringcentral-docker/jdk/jdk | |
NEW_ENTRY="| JDK${{ matrix.jdk_version }} | ${VERSION} | \`${IMAGE_NAME}:${VERSION}\` \`${IMAGE_NAME}:${VERSION}-${BASE_IMAGE}\` \`${IMAGE_NAME}:${DETAIL_VERSION}\` \`${IMAGE_NAME}:${DETAIL_VERSION}-${BASE_IMAGE}\` | \`${GH_DOCKER_PKG_IMAGE_NAME}:${VERSION}\` \`${GH_DOCKER_PKG_IMAGE_NAME}:${VERSION}-${BASE_IMAGE}\` \`${GH_DOCKER_PKG_IMAGE_NAME}:${DETAIL_VERSION}\` \`${GH_DOCKER_PKG_IMAGE_NAME}:${DETAIL_VERSION}-${BASE_IMAGE}\` |" | |
echo "${NEW_ENTRY}" > readme_updates_${{ matrix.jdk_version }}.txt | |
- 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@v2 | |
with: | |
name: readme-updates | |
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/*; 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 }} |