Skip to content

Commit 7411cc0

Browse files
author
Valentin REJAUNIER
committed
feat: add cli_image input to action.yml and update tests to utilize it
1 parent 2881194 commit 7411cc0

4 files changed

Lines changed: 36 additions & 25 deletions

File tree

.github/workflows/github-action-tests.yaml

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,30 @@ on:
77
pull_request:
88
workflow_dispatch:
99

10+
env:
11+
GO_VERSION: "1.25.0"
12+
CLI_IMAGE: escape-cli:pr-${{ github.sha }}
13+
1014
jobs:
11-
validate-action-definition:
15+
github-action-tests:
1216
runs-on: ubuntu-latest
1317
steps:
1418
- uses: actions/checkout@v6
1519

20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: ${{ env.GO_VERSION }}
23+
24+
- uses: goreleaser/goreleaser-action@v6
25+
with:
26+
install-only: true
27+
28+
- name: Build CLI image
29+
run: goreleaser release --snapshot --clean --skip=archive
30+
31+
- name: Tag image for action
32+
run: docker tag goreleaser.ko.local:latest "${CLI_IMAGE}"
33+
1634
- name: Verify action.yml structure
1735
run: |
1836
python3 -c "
@@ -32,57 +50,46 @@ jobs:
3250
print('action.yml is valid')
3351
"
3452
35-
test-missing-profile-id:
36-
runs-on: ubuntu-latest
37-
steps:
38-
- uses: actions/checkout@v6
39-
4053
- name: Run action without profile_id
41-
id: run
54+
id: missing_profile
4255
continue-on-error: true
4356
uses: ./
4457
with:
4558
api_key: "fake-key-for-testing"
59+
cli_image: ${{ env.CLI_IMAGE }}
4660

47-
- name: Assert failure
48-
if: steps.run.outcome == 'success'
61+
- name: Assert failure when profile_id is missing
62+
if: steps.missing_profile.outcome == 'success'
4963
run: |
5064
echo "Expected action to fail when profile_id is missing"
5165
exit 1
5266
53-
test-missing-api-key:
54-
runs-on: ubuntu-latest
55-
steps:
56-
- uses: actions/checkout@v4
57-
5867
- name: Run action without api_key
59-
id: run
68+
id: missing_api_key
6069
continue-on-error: true
6170
uses: ./
6271
with:
6372
profile_id: "fake-profile-id"
73+
cli_image: ${{ env.CLI_IMAGE }}
6474

65-
- name: Assert failure
66-
if: steps.run.outcome == 'success'
75+
- name: Assert failure when api_key is missing
76+
if: steps.missing_api_key.outcome == 'success'
6777
run: |
6878
echo "Expected action to fail when api_key is missing"
6979
exit 1
7080
71-
test-start-scan:
72-
runs-on: ubuntu-latest
73-
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
74-
steps:
75-
- uses: actions/checkout@v6
76-
7781
- name: Require E2E secrets
82+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
7883
run: |
7984
if [ -z "${{ secrets.E2E_API_KEY }}" ] || [ -z "${{ secrets.E2E_PROFILE_ID }}" ]; then
8085
echo "::error::Configure repository secrets E2E_API_KEY and E2E_PROFILE_ID for the Escape DAST scan."
8186
exit 1
8287
fi
8388
8489
- name: Run Escape DAST scan
90+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
8591
uses: ./
8692
with:
8793
profile_id: ${{ secrets.E2E_PROFILE_ID }}
8894
api_key: ${{ secrets.E2E_API_KEY }}
95+
cli_image: ${{ env.CLI_IMAGE }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Go
2+
dist/
23
*.exe
34
*.exe~
45
*.dll

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@ jobs:
3939
with:
4040
profile_id: ${{ secrets.ESCAPE_PROFILE_ID }}
4141
api_key: ${{ secrets.ESCAPE_API_KEY }}
42-
watch: "true"
4342
```

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ inputs:
2020
description: "Wait until the scan ends and print the results"
2121
required: false
2222
default: "false"
23+
cli_image:
24+
description: "Override the CLI Docker image. Defaults to the released version."
25+
required: false
2326

2427
# Deprecated
2528
timeout:
@@ -54,9 +57,10 @@ runs:
5457
ESCAPE_WATCH: ${{ inputs.watch }}
5558
ESCAPE_CONFIGURATION_OVERRIDE: ${{ inputs.configuration_override }}
5659
ESCAPE_SCHEMA: ${{ inputs.schema }}
60+
ESCAPE_CLI_IMAGE_OVERRIDE: ${{ inputs.cli_image }}
5761
run: |
5862
set -euo pipefail
59-
ESCAPE_CLI_IMAGE="docker.io/escapetech/cli:$(cat "$GITHUB_ACTION_PATH/version.txt")"
63+
ESCAPE_CLI_IMAGE="${ESCAPE_CLI_IMAGE_OVERRIDE:-docker.io/escapetech/cli:$(cat "$GITHUB_ACTION_PATH/version.txt")}"
6064
PROFILE_ID="${INPUT_PROFILE_ID:-}"
6165
if [ -z "${PROFILE_ID}" ]; then
6266
echo "profile_id is not set"

0 commit comments

Comments
 (0)