Skip to content

Commit

Permalink
:Robot: Cache triby DB before running the build (#2885)
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored Sep 25, 2024
1 parent 0ade99b commit fc77926
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/release-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ jobs:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Cache trivy DB
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: earthly +trivy
- name: Build 🔧
run: |
earthly -P +all-arm \
Expand Down Expand Up @@ -359,6 +365,12 @@ jobs:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Cache trivy DB
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: earthly +trivy
- name: Build 🔧
run: |
earthly -P +all-arm \
Expand Down Expand Up @@ -473,6 +485,12 @@ jobs:
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3
- name: Login to Quay Registry
run: echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
- name: Cache trivy DB
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: earthly +trivy
- name: Build iso 🔧
run: |
INIT=$([[ "${{ matrix.flavor }}" == "alpine" ]] && echo "openrc" || echo "systemd")
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ jobs:
with:
repository: quay.io/kairos/packages
packages: utils/earthly
- name: Cache trivy DB
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: earthly +trivy
- name: Build 🔧
run: |
earthly +all \
Expand Down Expand Up @@ -407,6 +413,12 @@ jobs:
packages: utils/earthly
- name: Login to Quay Registry
run: echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
- name: Cache trivy DB
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: earthly +trivy
- name: Build 🔧
run: |
earthly +all \
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/reusable-build-flavor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ jobs:
with:
repository: quay.io/kairos/packages
packages: system/kairos-agent
- name: Cache trivy DB
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: earthly +trivy
- name: Build master 🔧
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/reusable-build-provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ jobs:
with:
repository: quay.io/kairos/packages
packages: system/kairos-agent
- name: Cache trivy DB
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
command: earthly +trivy
- name: Build master 🔧
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
Expand Down
3 changes: 3 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,9 @@ datasource-iso:
trivy:
ARG TRIVY_VERSION
FROM aquasec/trivy:$TRIVY_VERSION
RUN /usr/local/bin/trivy fs --download-db-only
SAVE ARTIFACT /contrib contrib
SAVE ARTIFACT /root/.cache cache
SAVE ARTIFACT /usr/local/bin/trivy /trivy

trivy-scan:
Expand All @@ -781,6 +783,7 @@ trivy-scan:

COPY +trivy/trivy /trivy
COPY +trivy/contrib /contrib
COPY +trivy/cache /root/.cache

WORKDIR /build
RUN /trivy filesystem --skip-dirs /tmp --timeout 30m --format sarif -o report.sarif --no-progress /
Expand Down

0 comments on commit fc77926

Please sign in to comment.