Skip to content

Commit 4844d82

Browse files
authored
ci: fix workflow to bump Trivy (#466)
Signed-off-by: Nikita Pivkin <nikita.pivkin@smartforce.io>
1 parent 26d71e6 commit 4844d82

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

.github/workflows/bump-trivy.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
trivy_version:
77
required: true
88
type: string
9-
description: the trivy version
9+
description: 'The Trivy version in x.x.x format'
1010

1111
run-name: Bump trivy to v${{ inputs.trivy_version }}
1212

@@ -15,11 +15,12 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
18+
19+
- name: Set new version from input
20+
run: echo "NEW_VERSION=${{ inputs.trivy_version }}" >> $GITHUB_ENV
21+
1822
- name: Update Trivy versions
19-
run: |
20-
find test/data -type f -name '*.test' | xargs sed -r -i 's/"version": "[0-9]+\.[0-9]+\.[0-9]+"/"version": "${{ inputs.trivy_version }}"/'
21-
sed -r -i '/^\| `version`/ s/[0-9]+\.[0-9]+\.[0-9]+/${{ inputs.trivy_version }}/g' README.md
22-
sed -r -i 's/(default:[ ]*'"'"')v[0-9]+\.[0-9]+\.[0-9]+/\1v${{ inputs.trivy_version }}/' action.yaml
23+
run: make bump-trivy
2324

2425
- name: Create PR
2526
id: create-pr

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
OS := $(shell uname)
2+
SED = sed
3+
BATS_LIB_PATH = /usr/local/lib/
4+
25
ifeq ($(OS), Darwin)
3-
BATS_LIB_PATH=/opt/homebrew/lib
4-
endif
5-
ifeq ($(OS), Linux)
6-
BATS_LIB_PATH=/usr/local/lib/
6+
SED = gsed
7+
BATS_LIB_PATH = /opt/homebrew/lib
78
endif
89

9-
1010
.PHONY: test
1111
test:
1212
mkdir -p .cache
1313
BATS_LIB_PATH=$(BATS_LIB_PATH) GITHUB_REPOSITORY_OWNER=aquasecurity\
1414
TRIVY_CACHE_DIR=.cache TRIVY_DISABLE_VEX_NOTICE=true TRIVY_DEBUG=true\
1515
bats --recursive --timing --verbose-run .
16+
17+
bump-trivy:
18+
@[ $$NEW_VERSION ] || ( echo "env 'NEW_VERSION' is not set"; exit 1 )
19+
@CURRENT_VERSION=$$(grep "TRIVY_VERSION:" .github/workflows/test.yaml | awk '{print $$2}');\
20+
echo Current version: $$CURRENT_VERSION ;\
21+
echo New version: $$NEW_VERSION ;\
22+
$(SED) -i -e "s/$$CURRENT_VERSION/$$NEW_VERSION/g" README.md action.yaml .github/workflows/test.yaml ;\

0 commit comments

Comments
 (0)