-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
237 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Build and push Docker images | ||
name: Build Docker images | ||
|
||
inputs: | ||
image-name: | ||
|
@@ -84,65 +84,65 @@ runs: | |
- name: List manifest | ||
run: docker buildx imagetools inspect ${{ env.IMAGE_ID }}:${{ env.TAG }} | ||
shell: bash | ||
- name: Tag major version | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ${{ inputs.docker-context }} | ||
platforms: linux/amd64,linux/arm64 | ||
labels: | | ||
runnumber=${{ github.run_id }} | ||
build-args: | | ||
BASE_IMAGE=${{ inputs.base-image }} | ||
BASE_IMAGE_TAG=${{ env.MAJOR_VERSION }} | ||
TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
USER_IMAGE=${{ inputs.user-image }} | ||
push: true | ||
tags: ${{ env.IMAGE_ID }}:${{ env.MAJOR_VERSION }} | ||
provenance: false | ||
- name: Tag minor version | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ${{ inputs.docker-context }} | ||
platforms: linux/amd64,linux/arm64 | ||
labels: | | ||
runnumber=${{ github.run_id }} | ||
build-args: | | ||
BASE_IMAGE=${{ inputs.base-image }} | ||
BASE_IMAGE_TAG=${{ env.MINOR_VERSION }} | ||
TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
USER_IMAGE=${{ inputs.user-image }} | ||
push: true | ||
tags: ${{ env.IMAGE_ID }}:${{ env.MINOR_VERSION }} | ||
provenance: false | ||
- name: Tag latest | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ${{ inputs.docker-context }} | ||
platforms: linux/amd64,linux/arm64 | ||
labels: | | ||
runnumber=${{ github.run_id }} | ||
build-args: | | ||
BASE_IMAGE=${{ inputs.base-image }} | ||
BASE_IMAGE_TAG=latest | ||
TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
USER_IMAGE=${{ inputs.user-image }} | ||
push: true | ||
tags: ${{ env.IMAGE_ID }}:latest | ||
provenance: false | ||
- name: Scan for vulnerabilities | ||
uses: aquasecurity/[email protected] | ||
with: | ||
image-ref: ${{ env.IMAGE_ID }}:${{ env.TAG }} | ||
format: "sarif" | ||
output: "trivy-results.sarif" | ||
ignore-unfixed: true | ||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: "trivy-results.sarif" | ||
# - name: Tag major version | ||
# if: startsWith(github.ref, 'refs/tags/') | ||
# uses: docker/build-push-action@v6 | ||
# with: | ||
# context: ${{ inputs.docker-context }} | ||
# platforms: linux/amd64,linux/arm64 | ||
# labels: | | ||
# runnumber=${{ github.run_id }} | ||
# build-args: | | ||
# BASE_IMAGE=${{ inputs.base-image }} | ||
# BASE_IMAGE_TAG=${{ env.MAJOR_VERSION }} | ||
# TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
# TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
# USER_IMAGE=${{ inputs.user-image }} | ||
# push: true | ||
# tags: ${{ env.IMAGE_ID }}:${{ env.MAJOR_VERSION }} | ||
# provenance: false | ||
# - name: Tag minor version | ||
# if: startsWith(github.ref, 'refs/tags/') | ||
# uses: docker/build-push-action@v6 | ||
# with: | ||
# context: ${{ inputs.docker-context }} | ||
# platforms: linux/amd64,linux/arm64 | ||
# labels: | | ||
# runnumber=${{ github.run_id }} | ||
# build-args: | | ||
# BASE_IMAGE=${{ inputs.base-image }} | ||
# BASE_IMAGE_TAG=${{ env.MINOR_VERSION }} | ||
# TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
# TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
# USER_IMAGE=${{ inputs.user-image }} | ||
# push: true | ||
# tags: ${{ env.IMAGE_ID }}:${{ env.MINOR_VERSION }} | ||
# provenance: false | ||
# - name: Tag latest | ||
# if: startsWith(github.ref, 'refs/tags/') | ||
# uses: docker/build-push-action@v6 | ||
# with: | ||
# context: ${{ inputs.docker-context }} | ||
# platforms: linux/amd64,linux/arm64 | ||
# labels: | | ||
# runnumber=${{ github.run_id }} | ||
# build-args: | | ||
# BASE_IMAGE=${{ inputs.base-image }} | ||
# BASE_IMAGE_TAG=latest | ||
# TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
# TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
# USER_IMAGE=${{ inputs.user-image }} | ||
# push: true | ||
# tags: ${{ env.IMAGE_ID }}:latest | ||
# provenance: false | ||
# - name: Scan for vulnerabilities | ||
# uses: aquasecurity/[email protected] | ||
# with: | ||
# image-ref: ${{ env.IMAGE_ID }}:${{ env.TAG }} | ||
# format: "sarif" | ||
# output: "trivy-results.sarif" | ||
# ignore-unfixed: true | ||
# - name: Upload Trivy scan results to GitHub Security tab | ||
# uses: github/codeql-action/upload-sarif@v3 | ||
# with: | ||
# sarif_file: "trivy-results.sarif" |
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,136 @@ | ||
name: Push Docker image | ||
|
||
inputs: | ||
image-name: | ||
required: true | ||
type: string | ||
image-tag: | ||
required: true | ||
type: string | ||
docker-context: | ||
required: true | ||
type: string | ||
base-image: | ||
required: false | ||
type: string | ||
user-image: | ||
required: false | ||
type: string | ||
default: appuser | ||
ignore-linting-rules: | ||
required: false | ||
type: string | ||
github-token: | ||
required: true | ||
type: string | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
# - uses: hadolint/[email protected] | ||
# with: | ||
# dockerfile: ${{ inputs.docker-context }}/Dockerfile | ||
# ignore: SC1091,${{ inputs.ignore-linting-rules }} | ||
# - name: ShellCheck | ||
# run: | | ||
# cd ${{ inputs.docker-context }} | ||
# [ -d "./bin" ] && shellcheck --external-sources --exclude=SC1091 ./bin/* | ||
# shellcheck --external-sources --exclude=SC2148 ./Dockerfile | ||
# shell: bash | ||
- name: Log in to registry | ||
run: echo "${{ inputs.github-token }}" | docker login ghcr.io -u $ --password-stdin | ||
shell: bash | ||
- name: Prepare image tag | ||
id: generate-tags | ||
run: | | ||
VERSION_MAJOR=$(echo "${{ inputs.image-tag }}" | awk -F'.' '{print $1}') | ||
VERSION_MINOR=$(echo "${{ inputs.image-tag }}" | awk -F'.' '{print $2}') | ||
echo "TAG=$VERSION" >> "$GITHUB_ENV" | ||
echo "MAJOR_VERSION=$VERSION_MAJOR" >> "$GITHUB_ENV" | ||
echo "MINOR_VERSION=$VERSION_MAJOR.$VERSION_MINOR" >> "$GITHUB_ENV" | ||
shell: bash | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build and push images | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ${{ inputs.docker-context }} | ||
platforms: linux/amd64,linux/arm64 | ||
labels: | | ||
runnumber=${{ github.run_id }} | ||
build-args: | | ||
BASE_IMAGE=${{ inputs.base-image }} | ||
BASE_IMAGE_TAG=${{ env.TAG }} | ||
TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
USER_IMAGE=${{ inputs.user-image }} | ||
push: true | ||
tags: ${{ env.IMAGE_ID }}:${{ env.TAG }} | ||
provenance: false | ||
- name: List manifest | ||
run: docker buildx imagetools inspect ${{ env.IMAGE_ID }}:${{ env.TAG }} | ||
shell: bash | ||
- name: Tag major version | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ${{ inputs.docker-context }} | ||
platforms: linux/amd64,linux/arm64 | ||
labels: | | ||
runnumber=${{ github.run_id }} | ||
build-args: | | ||
BASE_IMAGE=${{ inputs.base-image }} | ||
BASE_IMAGE_TAG=${{ env.MAJOR_VERSION }} | ||
TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
USER_IMAGE=${{ inputs.user-image }} | ||
push: true | ||
tags: ${{ env.IMAGE_ID }}:${{ env.MAJOR_VERSION }} | ||
provenance: false | ||
- name: Tag minor version | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ${{ inputs.docker-context }} | ||
platforms: linux/amd64,linux/arm64 | ||
labels: | | ||
runnumber=${{ github.run_id }} | ||
build-args: | | ||
BASE_IMAGE=${{ inputs.base-image }} | ||
BASE_IMAGE_TAG=${{ env.MINOR_VERSION }} | ||
TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
USER_IMAGE=${{ inputs.user-image }} | ||
push: true | ||
tags: ${{ env.IMAGE_ID }}:${{ env.MINOR_VERSION }} | ||
provenance: false | ||
- name: Tag latest | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ${{ inputs.docker-context }} | ||
platforms: linux/amd64,linux/arm64 | ||
labels: | | ||
runnumber=${{ github.run_id }} | ||
build-args: | | ||
BASE_IMAGE=${{ inputs.base-image }} | ||
BASE_IMAGE_TAG=latest | ||
TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} | ||
TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile | ||
USER_IMAGE=${{ inputs.user-image }} | ||
push: true | ||
tags: ${{ env.IMAGE_ID }}:latest | ||
provenance: false | ||
- name: Scan for vulnerabilities | ||
uses: aquasecurity/[email protected] | ||
with: | ||
image-ref: ${{ env.IMAGE_ID }}:${{ env.TAG }} | ||
format: "sarif" | ||
output: "trivy-results.sarif" | ||
ignore-unfixed: true | ||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: "trivy-results.sarif" |
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
Oops, something went wrong.