build-publish-jenkins-jdk17-image #2
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-publish-jenkins-jdk17-image | |
on: | |
# push: | |
# branches: | |
# - main | |
workflow_dispatch: | |
schedule: | |
- cron: '30 10 5,20 * *' # morning 10:30 am on 5th and 20th of every month | |
permissions: | |
contents: write | |
run-name: build-publish-jenkins-jdk17-image | |
jobs: | |
build-publish-jenkins-jdk17-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set job start time | |
run: echo "JOB_START_TIME=$(date -u +"%d %B %A %Y %H:%M UTC")" >> $GITHUB_ENV | |
- name: Git config and create new tag | |
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 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
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 | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: | | |
${{ secrets.DOCKERHUB_USERNAME }}/jenkins-core-jdk17-image:${{ env.NEW_VERSION }} | |
${{ secrets.DOCKERHUB_USERNAME }}/jenkins-core-jdk17-image:latest | |
build-args: | | |
"JENKINS_USER=${{ secrets.JENKINS_USER }}" | |
"JENKINS_PASS=${{ secrets.JENKINS_PASS }}" | |
"GITHUB_APP_KEY=${{ secrets.GH_APP_KEY }}" | |
"GITHUB_APP_ID=${{ secrets.GH_APP_ID }}" | |
- name: set up docker and scan docker image for vulnerabilities | |
uses: docker-practice/actions-setup-docker@master | |
- run: | | |
set -x | |
docker version | |
docker run -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy image ${{ secrets.DOCKERHUB_USERNAME }}/jenkins-core-jdk17-image:latest | |
- name: Set job end time | |
run: echo "JOB_END_TIME=$(date -u +"%d %B %A %Y %H:%M UTC")" >> $GITHUB_ENV | |
- name: Write to workflow job summary | |
run: | | |
SUMMARY=$'# Building jenkins-core-image\n' | |
SUMMARY=$'[jenkins-core-jdk17-image available here](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-jdk17-image)\n' | |
SUMMARY+=$'**Job Start 📅 Time:** ${{ env.JOB_START_TIME }}\n' | |
SUMMARY+=$'**Job End 📅 Time:** ${{ env.JOB_END_TIME }}\n' | |
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY |