From 75d4af1780ef256fa401feef7cac72026ff53937 Mon Sep 17 00:00:00 2001 From: Krishnadhas N K <108367225+githubofkrishnadhas@users.noreply.github.com> Date: Mon, 15 Jul 2024 22:31:29 +0530 Subject: [PATCH] Feature/jdk17 jdk21 build (#6) * DEVOPS-258 jdk-17 and jdk 21 images * modify workflow * Updated readme and added status badges --- .../build-publish-jenkins-image.yaml | 4 +--- .../build-publish-jenkins-jdk17-image.yaml | 4 +--- .../build-publish-jenkins-jdk21-image.yaml | 4 +--- README.md | 20 +++++++++++++++++++ get_latest_version_create_tag.sh | 13 +++++------- version-jdk11.txt | 1 + version-jdk17.txt | 0 version-jdk21.txt | 0 8 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 version-jdk11.txt create mode 100644 version-jdk17.txt create mode 100644 version-jdk21.txt diff --git a/.github/workflows/build-publish-jenkins-image.yaml b/.github/workflows/build-publish-jenkins-image.yaml index 117f5f1..6feb6c1 100644 --- a/.github/workflows/build-publish-jenkins-image.yaml +++ b/.github/workflows/build-publish-jenkins-image.yaml @@ -26,7 +26,7 @@ jobs: if: github.ref == 'refs/heads/main' # Run only on main branch run: | # Run bash script to get new tag - bash get_latest_version_create_tag.sh + bash get_latest_version_create_tag.sh version-jdk11.txt - name: Log in to Docker Hub uses: docker/login-action@v3 @@ -41,8 +41,6 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build and publish docker image with tag -# env: -# NEW_VERSION: $NEW_VERSION uses: docker/build-push-action@v5 with: push: true diff --git a/.github/workflows/build-publish-jenkins-jdk17-image.yaml b/.github/workflows/build-publish-jenkins-jdk17-image.yaml index 358783b..a99bfef 100644 --- a/.github/workflows/build-publish-jenkins-jdk17-image.yaml +++ b/.github/workflows/build-publish-jenkins-jdk17-image.yaml @@ -26,7 +26,7 @@ jobs: if: github.ref == 'refs/heads/main' # Run only on main branch run: | # Run bash script to get new tag - bash get_latest_version_create_tag.sh + bash get_latest_version_create_tag.sh version-jdk17.txt - name: Log in to Docker Hub uses: docker/login-action@v3 @@ -41,8 +41,6 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build and publish docker image with tag -# env: -# NEW_VERSION: $NEW_VERSION uses: docker/build-push-action@v5 with: file: jdk-17/Dockerfile diff --git a/.github/workflows/build-publish-jenkins-jdk21-image.yaml b/.github/workflows/build-publish-jenkins-jdk21-image.yaml index 7635fa1..94d864b 100644 --- a/.github/workflows/build-publish-jenkins-jdk21-image.yaml +++ b/.github/workflows/build-publish-jenkins-jdk21-image.yaml @@ -26,7 +26,7 @@ jobs: if: github.ref == 'refs/heads/main' # Run only on main branch run: | # Run bash script to get new tag - bash get_latest_version_create_tag.sh + bash get_latest_version_create_tag.sh version-jdk21.txt - name: Log in to Docker Hub uses: docker/login-action@v3 @@ -41,8 +41,6 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build and publish docker image with tag -# env: -# NEW_VERSION: $NEW_VERSION uses: docker/build-push-action@v5 with: push: true diff --git a/README.md b/README.md index 7af1e47..2019d30 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,26 @@ # create-jenkins-docker-image-and-publish-periodically Create jenkins docker images and build them periodicaly and scan using trivy +[![Generic badge](https://img.shields.io/badge/maintained-yes-6acb14.svg)](https://shields.io/) +[![Generic badge](https://img.shields.io/badge/maintained%20by-githubofkrishnadhas-6acb14.svg)](https://shields.io/) + +[![build-publish-jenkins-jdk11-image](https://github.com/devwithkrishna/create-jenkins-docker-image-and-publish-periodically/actions/workflows/build-publish-jenkins-image.yaml/badge.svg)](https://github.com/devwithkrishna/create-jenkins-docker-image-and-publish-periodically/actions/workflows/build-publish-jenkins-image.yaml) +[![build-publish-jenkins-jdk17-image](https://github.com/devwithkrishna/create-jenkins-docker-image-and-publish-periodically/actions/workflows/build-publish-jenkins-jdk17-image.yaml/badge.svg)](https://github.com/devwithkrishna/create-jenkins-docker-image-and-publish-periodically/actions/workflows/build-publish-jenkins-jdk17-image.yaml) +[![build-publish-jenkins-jdk21-image](https://github.com/devwithkrishna/create-jenkins-docker-image-and-publish-periodically/actions/workflows/build-publish-jenkins-jdk21-image.yaml/badge.svg)](https://github.com/devwithkrishna/create-jenkins-docker-image-and-publish-periodically/actions/workflows/build-publish-jenkins-jdk21-image.yaml) + +![Github stars](https://badgen.net/github/stars/devwithkrishna/create-jenkins-docker-image-and-publish-periodically?icon=github&label=stars) +![Github forks](https://badgen.net/github/forks/devwithkrishna/create-jenkins-docker-image-and-publish-periodically?icon=github&label=forks) +![Github issues](https://img.shields.io/github/issues/devwithkrishna/create-jenkins-docker-image-and-publish-periodically) +![Github last commit](https://img.shields.io/github/last-commit/devwithkrishna/create-jenkins-docker-image-and-publish-periodically) + +[![Docker Pulls](https://badgen.net/docker/pulls/dockerofkrishnadhas/jenkins-core-image?icon=docker&label=jenkins-core-image%20pulls)](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-image/) +[![Docker Pulls](https://badgen.net/docker/pulls/dockerofkrishnadhas/jenkins-core-jdk17-image?icon=docker&label=jenkins-core-jdk17-image%20pulls)](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-jdk17-image/) +[![Docker Pulls](https://badgen.net/docker/pulls/dockerofkrishnadhas/jenkins-core-jdk21-image?icon=docker&label=jenkins-core-jdk21-image%20pulls)](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-jdk21-image/) + +[![Docker Image Size](https://badgen.net/docker/size/dockerofkrishnadhas/jenkins-core-image?icon=docker&label=jenkins-core-image-image%20size)](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-image/) +[![Docker Image Size](https://badgen.net/docker/size/dockerofkrishnadhas/jenkins-core-jdk17-image?icon=docker&label=jenkins-core-jdk17-image%20size)](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-jdk17-image/) +[![Docker Image Size](https://badgen.net/docker/size/dockerofkrishnadhas/jenkins-core-jdk21-image?icon=docker&label=jenkins-core-jdk21-image%20size)](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-jdk21-image/) + # Images being built and updated | Image Name | jdk version | diff --git a/get_latest_version_create_tag.sh b/get_latest_version_create_tag.sh index 21762aa..0c12f8b 100644 --- a/get_latest_version_create_tag.sh +++ b/get_latest_version_create_tag.sh @@ -17,9 +17,9 @@ increment_version() { echo "${prefix}${part1}.$((part2+1))" # Increment patch by 1. fi } - -# Read the current version from the version file and trim any trailing newlines -VERSION=$(cat version.txt | tr -d '\n') +file_name=$1 +# Read the current version from the version file which is received as a input param and trim any trailing newlines +VERSION=$(cat $1 | tr -d '\n') echo "Current version read from version.txt: $VERSION" # Increment the version @@ -37,12 +37,9 @@ git config --local user.email "devwithkrishna-github-actions[bot]@users.noreply. git config --local user.name "devwithkrishna github actions [bot]" # Commit the version file update -git add version.txt +git add version*.txt git status -git commit --author="devwithkrishna github actions [bot] " -m "Increment version to $NEW_VERSION" - -# Tag the commit with the new version -git tag -a $NEW_VERSION -m "Release version $NEW_VERSION" +git commit --author="devwithkrishna github actions [bot] " -m "Increment version in $1 to $NEW_VERSION" # Push the commit and the tag to the remote repository git push origin main --follow-tags diff --git a/version-jdk11.txt b/version-jdk11.txt new file mode 100644 index 0000000..6a2b0ac --- /dev/null +++ b/version-jdk11.txt @@ -0,0 +1 @@ +v1.0.1 \ No newline at end of file diff --git a/version-jdk17.txt b/version-jdk17.txt new file mode 100644 index 0000000..e69de29 diff --git a/version-jdk21.txt b/version-jdk21.txt new file mode 100644 index 0000000..e69de29