Skip to content

Commit

Permalink
Create composite actions to build and scan image
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfangAukang committed Sep 29, 2023
1 parent 6931d1a commit 9377936
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 56 deletions.
27 changes: 27 additions & 0 deletions .github/actions/build-and-verify-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Build and Verify Image"
description: Common action to build and verify SimpleRisk Docker images

inputs:
image_tag:
description: "Tag used to build the image"
context_path:
description: "Path to context"
dockerfile_path:
description: "Path to Dockerfile"

runs:
using: "composite"
steps:
- uses: docker/setup-buildx-action@v3
- name: Build Docker container
uses: docker/build-push-action@v5
with:
context: ${{inputs.context_path}}
file: ${{inputs.dockerfile_path}}
tags: ${{inputs.image_tag}}
- name: Scan vulnerabilities with Grype
uses: anchore/[email protected]
with:
image: ${{inputs.image_tag}}
only-fixed: true
severity-cutoff: critical
7 changes: 3 additions & 4 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ name: Shell script checkup with ShellCheck

on:
pull_request:
branch:
- master
branches: [ master ]

jobs:
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4.1.0
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
severity: error
severity: error
25 changes: 0 additions & 25 deletions .github/workflows/simplerisk-jammy-build.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/simplerisk-jammy-push_to_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4.1.0

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/simplerisk-jammy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Full checkup for SimpleRisk Docker images

on:
pull_request:
branches: [ master ]

env:
IMAGE_TAG: "simplerisk/simplerisk:testing"
CONTEXT_PATH: "simplerisk/"
DOCKERFILE_PATH: "simplerisk/jammy/Dockerfile"
DOCKLE_HOST: "unix:///var/run/docker.sock"

jobs:
simplerisk-minimal-php81:
name: 'Verify simplerisk/simplerisk image based on Ubuntu 22.04 (Jammy)'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Build and Verify Image
uses: ./.github/actions/build-and-verify-image
with:
image_tag: "${{ env.IMAGE_TAG }}"
context_path: "${{ env.CONTEXT_PATH }}"
dockerfile_path: "${{ env.DOCKERFILE_PATH }}"
# Having issues using this on the composite action above
- name: Run linter with Dockle
uses: erzz/[email protected]
with:
image: ${{inputs.image_tag}}
failure-threshold: FATAL
dockle-host: "unix:///var/run/docker.sock"
25 changes: 0 additions & 25 deletions .github/workflows/simplerisk-minimal-php81-build.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4.1.0

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/simplerisk-minimal-php81.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Full checkup for SimpleRisk Docker images

on:
pull_request:
branches: [ master ]

env:
IMAGE_TAG: "simplerisk/simplerisk-minimal:testing"
CONTEXT_PATH: "simplerisk-minimal/"
DOCKERFILE_PATH: "simplerisk-minimal/php81/Dockerfile"
DOCKLE_HOST: "unix:///var/run/docker.sock"

jobs:
simplerisk-minimal-php81:
name: 'Verify simplerisk/simplerisk-minimal image based on php:8.1-apache'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Build and Verify Image
uses: ./.github/actions/build-and-verify-image
with:
image_tag: "${{ env.IMAGE_TAG }}"
context_path: "${{ env.CONTEXT_PATH }}"
dockerfile_path: "${{ env.DOCKERFILE_PATH }}"
# Having issues using this on the composite action above
- name: Run linter with Dockle
uses: erzz/[email protected]
with:
image: ${{inputs.image_tag}}
failure-threshold: FATAL
dockle-host: "unix:///var/run/docker.sock"

0 comments on commit 9377936

Please sign in to comment.