-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fully Templated Docker cached build job
Fully Templated Docker cached build job - most parameters are defaulted based on git variables - all of defaulted parameters can be overwritten using inputs - fixes to existing workflows due to naming convention miss-match between action pull_request and push Signed-off-by: Milosz Linkiewicz <[email protected]>
- Loading branch information
Showing
13 changed files
with
199 additions
and
355 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ env: | |
LINTER_RULES_PATH: .github/configs/super-linter | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || env.GITHUB_SHA }} | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
|
@@ -46,7 +46,7 @@ jobs: | |
fetch-depth: 0 | ||
ref: ${{ inputs.branch }} | ||
|
||
- name: 'super-linter: perform supe-linter scan workflow.' | ||
- name: 'super-linter: perform super-linter scan workflow.' | ||
uses: super-linter/[email protected] # x-release-please-version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
name: template-docker-cached-build | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
build_type: | ||
required: false | ||
type: string | ||
default: 'Release' | ||
docker_registry: | ||
required: false | ||
type: string | ||
default: 'ghcr.io' | ||
docker_registry_prefix: | ||
required: false | ||
type: string | ||
default: 'openvisualcloud/media-communications-mesh' | ||
docker_registry_login: | ||
required: false | ||
type: boolean | ||
default: false | ||
docker_registry_push: | ||
required: false | ||
type: boolean | ||
default: false | ||
docker_build_args: | ||
required: false | ||
type: string | ||
default: '' | ||
docker_build_platforms: | ||
required: false | ||
type: string | ||
default: 'linux/amd64' | ||
docker_image_tag: | ||
required: false | ||
type: string | ||
docker_image_name: | ||
required: true | ||
type: string | ||
docker_file_path: | ||
required: false | ||
type: string | ||
default: './Dockerfile' | ||
secrets: | ||
docker_registry_login: | ||
required: false | ||
docker_registry_passkey: | ||
required: false | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
scan-and-build-docker-image: | ||
name: "${{ inputs.docker_image_name }}: Performing scan and build of Dockerfile." | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: read | ||
security-events: write | ||
timeout-minutes: 60 | ||
env: | ||
BUILD_TYPE: "${{ inputs.build_type }}" | ||
CONCURRENCY_GROUP: "${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}" | ||
DOCKER_REGISTRY: "${{ inputs.docker_registry }}" | ||
DOCKER_REGISTRY_LOGIN: "${{ github.repository == 'openvisualcloud/media-communications-mesh' && inputs.docker_registry_login }}" | ||
DOCKER_BUILD_ARGS: "${{ inputs.docker_build_args }}" | ||
DOCKER_PLATFORMS: "${{ inputs.docker_build_platforms }}" | ||
DOCKER_IMAGE_PUSH: "${{ github.repository == 'openvisualcloud/media-communications-mesh' && inputs.docker_registry_push }}" | ||
DOCKER_IMAGE_BASE: "${{ inputs.docker_registry }}/${{ inputs.docker_registry_prefix }}" | ||
DOCKER_IMAGE_TAG: "${{ inputs.docker_image_tag || github.sha }}" | ||
DOCKER_IMAGE_NAME: "${{ inputs.docker_image_name }}" | ||
DOCKER_FILE_PATH: "${{ inputs.docker_file_path }}" | ||
steps: | ||
- name: "${{ inputs.docker_image_name }}: Harden Runner" | ||
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 | ||
with: | ||
egress-policy: audit | ||
|
||
- name: "${{ inputs.docker_image_name }}: Set up Docker Buildx" | ||
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3.4.0 | ||
with: | ||
buildkitd-flags: --debug | ||
|
||
- name: "${{ inputs.docker_image_name }}: Checkout repository" | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: "${{ inputs.docker_image_name }}: Scanner Hadolint Dockerfile scan sarif format" | ||
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0 | ||
with: | ||
dockerfile: "${{ env.DOCKER_FILE_PATH }}" | ||
config: .github/configs/hadolint.yaml | ||
format: sarif | ||
output-file: "hadolint-${{ env.CONCURRENCY_GROUP }}-${{ env.DOCKER_IMAGE_NAME }}-${{ env.DOCKER_IMAGE_TAG }}.sarif" | ||
no-fail: true | ||
failure-threshold: info | ||
|
||
- name: "${{ inputs.docker_image_name }}: Scanner Hadolint upload results to Security tab" | ||
uses: github/codeql-action/upload-sarif@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 | ||
with: | ||
sarif_file: "hadolint-${{ env.CONCURRENCY_GROUP }}-${{ env.DOCKER_IMAGE_NAME }}-${{ env.DOCKER_IMAGE_TAG }}.sarif" | ||
|
||
- name: "${{ inputs.docker_image_name }}: Login to Docker Container Registry" | ||
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | ||
if: ${{ env.DOCKER_REGISTRY_LOGIN == 'true' }} | ||
with: | ||
registry: "${{ env.DOCKER_REGISTRY }}" | ||
username: "${{ secrets.docker_registry_login || env.GITHUB_ACTOR }}" | ||
password: "${{ secrets.docker_registry_passkey || secrets.GITHUB_TOKEN }}" | ||
|
||
- name: "${{ inputs.docker_image_name }}: Build and push image" | ||
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c # v6.3.0 | ||
with: | ||
load: true | ||
push: "${{ env.DOCKER_IMAGE_PUSH }}" | ||
outputs: type=docker | ||
platforms: "${{ env.DOCKER_PLATFORMS }}" | ||
file: "${{ env.DOCKER_FILE_PATH }}" | ||
tags: "${{ env.DOCKER_IMAGE_BASE }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }}" | ||
cache-from: type=gha,scope=${{ env.DOCKER_IMAGE_NAME }} | ||
cache-to: type=gha,mode=max,scope=${{ env.DOCKER_IMAGE_NAME }} | ||
build-args: "${{ env.DOCKER_BUILD_ARGS }}" | ||
|
||
- name: "${{ inputs.docker_image_name }}: Scanner Trivy run vulnerability scanner on image" | ||
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # v0.29.0 | ||
with: | ||
image-ref: "${{ env.DOCKER_IMAGE_BASE }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }}" | ||
format: "sarif" | ||
output: "${{ env.CONCURRENCY_GROUP }}-${{ env.DOCKER_IMAGE_NAME }}-${{ env.DOCKER_IMAGE_TAG }}.sarif" | ||
|
||
- name: "${{ inputs.docker_image_name }}: Scanner Trivy upload results to Security tab" | ||
uses: github/codeql-action/upload-sarif@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 | ||
with: | ||
sarif_file: "${{ env.CONCURRENCY_GROUP }}-${{ env.DOCKER_IMAGE_NAME }}-${{ env.DOCKER_IMAGE_TAG }}.sarif" | ||
|
||
- name: "${{ inputs.docker_image_name }}: Scanner Hadolint Dockerfile scan tty output" | ||
if: always() | ||
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0 | ||
with: | ||
dockerfile: "${{ env.DOCKER_FILE_PATH }}" | ||
config: .github/configs/hadolint.yaml | ||
format: tty | ||
failure-threshold: warning |
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
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
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
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
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