-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADMIN] Add Github Composite Actions for Docker images (#68)
- Loading branch information
1 parent
b78e004
commit 4abea14
Showing
5 changed files
with
147 additions
and
56 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: 'Docker Build' | ||
description: 'Docker Build' | ||
|
||
inputs: | ||
folder: | ||
description: 'Folder of the Docker image' | ||
required: true | ||
image_build: | ||
description: 'Name of the build image' | ||
required: true | ||
image_latest: | ||
description: 'Name of the latest image in the repository' | ||
required: true | ||
|
||
outputs: | ||
build_output: | ||
description: 'Output of the build step' | ||
value: ${{ steps.build.outputs.build_output }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: 🔨 Building the image | ||
id: build | ||
shell: bash | ||
run: | | ||
output="$(docker build . -f ${{ inputs.folder }}/Dockerfile -t ${{ inputs.image_build }} --cache-from ${{ inputs.image_latest }})" | ||
# Needed to avoid truncating multilines (https://github.com/actions/toolkit/issues/403) | ||
output="${output//'%'/'%25'}" | ||
output="${output//$'\n'/'%0A'}" | ||
output="${output//$'\r'/'%0D'}" | ||
# Set output | ||
echo $output | ||
echo "::set-output name=build_output::$output" |
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,44 @@ | ||
name: 'Docker Push to GCR' | ||
description: 'Docker Push to GCR' | ||
|
||
inputs: | ||
image_local: | ||
description: 'Name of the local image built' | ||
required: true | ||
image_remote: | ||
description: 'Name of the remote image to push' | ||
required: true | ||
registry: | ||
description: 'GCR registry' | ||
required: true | ||
version_file: | ||
description: 'Path of the file containing the VERSION number' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: 📊 Obtain version | ||
id: obtain_version | ||
shell: bash | ||
run: | | ||
version=$(cat ${{ inputs.version_file }}) | ||
echo "🎉 Found version: ${version}" | ||
echo "::set-output name=tag::$version" | ||
- name: 🚀 Push image to GitHub Container Registry | ||
id: push | ||
shell: bash | ||
run: | | ||
REMOTE_IMAGE=${{ inputs.registry }}/${{ inputs.image_remote }} | ||
IMAGE_VERSION=${{ steps.obtain_version.outputs.tag }} | ||
echo "🏷 Tagging image" | ||
docker tag ${{ inputs.image_local }} ${REMOTE_IMAGE}:${IMAGE_VERSION} | ||
docker tag ${{ inputs.image_local }} ${REMOTE_IMAGE}:latest | ||
echo "⚙️ Pushing ${REMOTE_IMAGE}:${IMAGE_VERSION}" | ||
docker push ${REMOTE_IMAGE}:${IMAGE_VERSION} | ||
echo "⚙️ Pushing ${REMOTE_IMAGE}:latest" | ||
docker push ${REMOTE_IMAGE}:latest |
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,26 @@ | ||
name: 'Trivy' | ||
description: 'Trivy' | ||
|
||
inputs: | ||
image_name: | ||
description: 'Name of the image' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
# | ||
# Scan | ||
# | ||
- name: 🛡 Run Trivy vulnerability scanner | ||
# TODO: currently not allowed in composite actions | ||
# continue-on-error: true | ||
uses: aquasecurity/trivy-action@0.0.20 | ||
id: scan | ||
with: | ||
image-ref: ${{ inputs.image_name }} | ||
format: 'table' | ||
# WARN ONLY | ||
exit-code: '0' | ||
ignore-unfixed: true | ||
severity: 'CRITICAL,HIGH' |
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 |
---|---|---|
@@ -1 +1 @@ | ||
1 | ||
1.1 |