Skip to content

Docker Image CI

Docker Image CI #56

Workflow file for this run

name: Docker Image CI
on:
schedule:
- cron: '30 14 * * *'
push:
tags:
- '*.**.**'
paths-ignore:
- '**.md'
- '**.png'
- '**.jpg'
- '**.svg'
- '**.yaml'
- CNAME
- LICENSE
jobs:
shellcheck:
name: Check shell scripts
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: shellcheck
uses: reviewdog/action-shellcheck@v1
with:
reporter: github-pr-review
pattern: "*.sh"
exclude: "./.git/*"
mdlint:
name: MarkdownLint
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: markdownlint-cli
uses: nosborn/github-action-markdown-cli@v3.3.0
with:
files: .
config_file: .markdownlint.yaml
ignore_files: ./LICENSE
build_base_images_focal:
name: Building a basic docker image on focal
needs: [shellcheck, mdlint]
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile.base-focal
- name: Log in to Docker Hub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
latest=false
suffix=-base-focal,onlatest=true
tags: |
type=semver,pattern={{version}}
type=schedule,pattern=latest
- name: Build and push Docker base focal
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.base-focal
build_base_images_jammy:
name: Building a basic docker image on jammy
needs: [shellcheck, mdlint]
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile.base-jammy
- name: Log in to Docker Hub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
latest=false
suffix=-base-jammy,onlatest=true
tags: |
type=semver,pattern={{version}}
type=schedule,pattern=latest
- name: Build and push Docker base jammy
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.base-jammy
build_standart_image:
needs: [build_base_images_jammy]
name: Build standart image
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
- name: Log in to Docker Hub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}}
type=schedule,pattern=latest
- name: Set tag
id: tag
shell: bash
run: |
if [[ $GITHUB_REF_TYPE == "tag" ]] ; then
echo "PROJECT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF_TYPE == "branch" ]] ; then
echo "PROJECT_TAG=latest" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile
build-args: |
BASE_IMAGE_NAME=${{ github.repository }}
BASE_IMAGE_TAG=${{ steps.tag.outputs.PROJECT_TAG }}-base-jammy
build_gradle_733_image:
needs: [build_base_images_jammy]
name: Build Gradle 7.3.3 image
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile.gradle-7.3.3
- name: Log in to Docker Hub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
latest=false
suffix=-gradle-7.3.3,onlatest=true
tags: |
type=semver,pattern={{version}}
type=schedule,pattern=latest
- name: Set tag
id: tag
shell: bash
run: |
if [[ $GITHUB_REF_TYPE == "tag" ]] ; then
echo "PROJECT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF_TYPE == "branch" ]] ; then
echo "PROJECT_TAG=latest" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker Gradle 7.3.3
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.gradle-7.3.3
build-args: |
BASE_IMAGE_NAME=${{ github.repository }}
BASE_IMAGE_TAG=${{ steps.tag.outputs.PROJECT_TAG }}-base-jammy
build_gradle_811_image:
needs: [build_base_images_jammy]
name: Build Gradle 8.1.1 image
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile.gradle-8.1.1
- name: Log in to Docker Hub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
latest=false
suffix=-gradle-8.1.1,onlatest=true
tags: |
type=semver,pattern={{version}}
type=schedule,pattern=latest
- name: Set tag
id: tag
shell: bash
run: |
if [[ $GITHUB_REF_TYPE == "tag" ]] ; then
echo "PROJECT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF_TYPE == "branch" ]] ; then
echo "PROJECT_TAG=latest" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker Gradle 8.1.1
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.gradle-8.1.1
build-args: |
BASE_IMAGE_NAME=${{ github.repository }}
BASE_IMAGE_TAG=${{ steps.tag.outputs.PROJECT_TAG }}-base-jammy
build_dotnet_31_image:
needs: [build_base_images_focal]
name: Build .Net 3.1 image
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile.dotnet-3.1
- name: Log in to Docker Hub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
latest=false
suffix=-dotnet-3.1,onlatest=true
tags: |
type=semver,pattern={{version}}
type=schedule,pattern=latest
- name: Set tag
id: tag
shell: bash
run: |
if [[ $GITHUB_REF_TYPE == "tag" ]] ; then
echo "PROJECT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF_TYPE == "branch" ]] ; then
echo "PROJECT_TAG=latest" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker .Net-3.1
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.dotnet-3.1
build-args: |
BASE_IMAGE_NAME=${{ github.repository }}
BASE_IMAGE_TAG=${{ steps.tag.outputs.PROJECT_TAG }}-base-focal
build_dotnet_5_image:
needs: [build_base_images_focal]
name: Build .Net 5.0 image
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile.dotnet-5.0
- name: Log in to Docker Hub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
latest=false
suffix=-dotnet-5.0,onlatest=true
tags: |
type=semver,pattern={{version}}
type=schedule,pattern=latest
- name: Set tag
id: tag
shell: bash
run: |
if [[ $GITHUB_REF_TYPE == "tag" ]] ; then
echo "PROJECT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF_TYPE == "branch" ]] ; then
echo "PROJECT_TAG=latest" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker .Net-5.0
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}-dotnet-5.0
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.dotnet-5.0
build-args: |
BASE_IMAGE_NAME=${{ github.repository }}
BASE_IMAGE_TAG=${{ steps.tag.outputs.PROJECT_TAG }}-base-focal
build_dotnet_6_image:
needs: [build_base_images_jammy]
name: Build .Net 6.0 image
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile.dotnet-6.0
- name: Log in to Docker Hub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
latest=false
suffix=-dotnet-6.0,onlatest=true
tags: |
type=semver,pattern={{version}}
type=schedule,pattern=latest
- name: Set tag
id: tag
shell: bash
run: |
if [[ $GITHUB_REF_TYPE == "tag" ]] ; then
echo "PROJECT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF_TYPE == "branch" ]] ; then
echo "PROJECT_TAG=latest" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker .Net-6.0
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.dotnet-6.0
build-args: |
BASE_IMAGE_NAME=${{ github.repository }}
BASE_IMAGE_TAG=${{ steps.tag.outputs.PROJECT_TAG }}-base-jammy
build_dotnet_7_image:
needs: [build_base_images_jammy]
name: Build .Net 7.0 image
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile.dotnet-7.0
- name: Log in to Docker Hub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: |
latest=false
suffix=-dotnet-7.0,onlatest=true
tags: |
type=semver,pattern={{version}}
type=schedule,pattern=latest
- name: Set tag
id: tag
shell: bash
run: |
if [[ $GITHUB_REF_TYPE == "tag" ]] ; then
echo "PROJECT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF_TYPE == "branch" ]] ; then
echo "PROJECT_TAG=latest" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker .Net-7.0
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile.dotnet-7.0
build-args: |
BASE_IMAGE_NAME=${{ github.repository }}
BASE_IMAGE_TAG=${{ steps.tag.outputs.PROJECT_TAG }}-base-jammy
release:
needs:
- build_standart_image
- build_gradle_733_image
- build_gradle_811_image
- build_dotnet_31_image
- build_dotnet_5_image
- build_dotnet_6_image
- build_dotnet_7_image
name: Release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Set env
id: env
run: |
echo "PROJECT_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "PROJECT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "PROJECT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Standart image:
* `docker pull ghcr.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}`
* `docker pull docker.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}`
Gradle images:
* `docker pull ghcr.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-gradle-7.3.3`
* `docker pull ghcr.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-gradle-8.1.1`
* `docker pull docker.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-gradle-7.3.3`
* `docker pull docker.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-gradle-8.1.1`
.Net images:
* `docker pull ghcr.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-dotnet-3.1`
* `docker pull ghcr.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-dotnet-5.0`
* `docker pull ghcr.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-dotnet-6.0`
* `docker pull ghcr.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-dotnet-7.0`
* `docker pull docker.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-dotnet-3.1`
* `docker pull docker.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-dotnet-5.0`
* `docker pull docker.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-dotnet-6.0`
* `docker pull docker.io/sentoz/multi-sonarqube-scanner-cli:${{ steps.env.outputs.PROJECT_TAG }}-dotnet-7.0`
draft: false
prerelease: false