-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
dbe09c4
commit 0061ca5
Showing
4 changed files
with
108 additions
and
54 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,56 @@ | ||
name: Build ROCK | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
on: | ||
pull_request: | ||
workflow_call: | ||
outputs: | ||
rock: | ||
description: "The rock output of build process." | ||
value: ${{ jobs.build.outputs.rock }} | ||
|
||
jobs: | ||
build: | ||
name: Build Rock | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup LXD | ||
uses: canonical/setup-lxd@main | ||
|
||
- name: Install dependencies | ||
run: | | ||
# docker | ||
sudo snap install docker | ||
sudo addgroup --system docker; sudo adduser $USER docker | ||
newgrp docker | ||
sudo snap disable docker; sudo snap enable docker | ||
# skopeo | ||
sudo snap install --devmode --channel edge skopeo | ||
# rockcraft | ||
sudo snap install rockcraft --classic --edge | ||
# jq and yq | ||
sudo snap install jq yq | ||
- name: Build ROCK | ||
id: build | ||
run: | | ||
rockcraft pack --verbose | ||
VERSION=$(yq '.version' rockcraft.yaml) | ||
echo "rock=charmed-opensearch_${VERSION}_amd64.rock" >> $GITHUB_OUTPUT | ||
- name: Upload locally built ROCK artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: charmed-opensearch | ||
path: ${{ steps.build.outputs.rock }} | ||
|
||
outputs: | ||
rock: ${{ steps.build.outputs.rock }} |
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,50 @@ | ||
name: Trivy Security Scanner | ||
on: | ||
push: | ||
branches: | ||
- main | ||
schedule: | ||
- cron: '53 0 * * *' # Daily at 00:53 UTC | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/build.yaml | ||
|
||
scan: | ||
name: Trivy scan | ||
needs: | ||
- build | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install skopeo | ||
run: | | ||
sudo snap install --devmode --channel edge skopeo | ||
sudo snap install yq | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: charmed-opensearch | ||
|
||
- name: Import locally | ||
run: | | ||
sudo skopeo --insecure-policy copy \ | ||
oci-archive:${{ needs.build.outputs.rock }} \ | ||
docker-daemon:trivy/charmed-opensearch:test | ||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: 'trivy/charmed-opensearch:test' | ||
format: 'sarif' | ||
output: 'trivy-results.sarif' | ||
severity: 'MEDIUM,HIGH,CRITICAL' | ||
|
||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v2 | ||
if: always() | ||
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