Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/jdk17 jdk21 build #6

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/build-publish-jenkins-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/build-publish-jenkins-jdk17-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/build-publish-jenkins-jdk21-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 |
Expand Down
13 changes: 5 additions & 8 deletions get_latest_version_create_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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] <devwithkrishna-github-actions[bot]@users.noreply.github.com>" -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] <devwithkrishna-github-actions[bot]@users.noreply.github.com>" -m "Increment version in $1 to $NEW_VERSION"

# Push the commit and the tag to the remote repository
git push origin main --follow-tags
1 change: 1 addition & 0 deletions version-jdk11.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.1
Empty file added version-jdk17.txt
Empty file.
Empty file added version-jdk21.txt
Empty file.