Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Sep 30, 2024
1 parent 69549dd commit 36d8bff
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions .github/workflows/cache-test-images.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Cache test images
on:
schedule:
- cron: "0 0 * * *" # Every day in 00:00
workflow_dispatch:

env:
GO_VERSION: '1.22'
jobs:
test-images:
name: Cache test images
Expand All @@ -15,32 +15,34 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: go.mod

- name: Install tools
uses: aquaproj/aqua-installer@v3.0.1
with:
aqua_version: v1.25.0

- name: Download test images
if: github.ref == 'refs/heads/main'
run: mage test:fixtureContainerImages

- name: Generate image list digest
if: github.ref == 'refs/heads/main'
if: github.ref_name == 'main'
id: image-digest
run: |
IMAGE_LIST=$(skopeo list-tags docker://ghcr.io/aquasecurity/trivy-test-images)
DIGEST=$(echo "$IMAGE_LIST" | sha256sum | cut -d' ' -f1)
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
## We need to save test image cache only for main branch
- name: Save test images into cache
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@v4
## We need to work with test image cache only for main branch
- name: Restore and save test images cache
if: github.ref_name == 'main'
uses: actions/cache@v4
with:
path: integration/testdata/fixtures/images
key: cache-test-images-${{ steps.image-digest.outputs.digest }}
restore-keys:
cache-test-images-

- name: Download test images
if: github.ref_name == 'main'
run: mage test:fixtureContainerImages

test-vm-images:
name: Cache test VM images
Expand All @@ -52,29 +54,31 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: go.mod

- name: Install tools
uses: aquaproj/aqua-installer@v3.0.1
with:
aqua_version: v1.25.0

- name: Download test VM images
if: github.ref == 'refs/heads/main'
run: mage test:fixtureVMImages

- name: Generate image list digest
if: github.ref == 'refs/heads/main'
if: github.ref_name == 'main'
id: image-digest
run: |
IMAGE_LIST=$(skopeo list-tags docker://ghcr.io/aquasecurity/trivy-test-vm-images)
DIGEST=$(echo "$IMAGE_LIST" | sha256sum | cut -d' ' -f1)
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
## We need to save test VM image cache only for main branch
- name: Save test VM images into cache
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@v4
## We need to work with test VM image cache only for main branch
- name: Restore and save test VM images into cache
if: github.ref_name == 'main'
uses: actions/cache@v4
with:
path: integration/testdata/fixtures/vm-images
key: cache-test-vm-images-${{ steps.image-digest.outputs.digest }}
key: cache-test-vm-images-${{ steps.image-digest.outputs.digest }}
restore-keys:
cache-test-vm-images-

- name: Download test VM images
if: github.ref_name == 'main'
run: mage test:fixtureVMImages

0 comments on commit 36d8bff

Please sign in to comment.