Skip to content

Commit 7838d48

Browse files
feat: Mount Temp Directory to KICS container (#13)
1 parent 9caac5e commit 7838d48

File tree

4 files changed

+33
-108
lines changed

4 files changed

+33
-108
lines changed

.github/workflows/release.yaml

Lines changed: 31 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@ on:
66
- main
77
- master
88
workflow_dispatch:
9-
inputs:
10-
version_type:
11-
description: 'Type of version bump'
12-
required: false
13-
default: 'auto'
14-
type: choice
15-
options:
16-
- auto
17-
- patch
18-
- minor
19-
- major
209

2110
jobs:
2211
release:
@@ -52,7 +41,7 @@ jobs:
5241
- name: Setup Node.js
5342
uses: actions/setup-node@v4
5443
with:
55-
node-version: '20'
44+
node-version: "20"
5645

5746
- name: Install semantic-release dependencies
5847
run: |
@@ -66,64 +55,32 @@ jobs:
6655
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6756
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6857
run: |
69-
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.version_type }}" != "auto" ]]; then
70-
# Manual release with specified version type
71-
echo "Manual release triggered with version type: ${{ github.event.inputs.version_type }}"
72-
npx semantic-release --dry-run > release_output.txt 2>&1 || true
73-
74-
# Extract current version and calculate next version
75-
CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
76-
CURRENT_VERSION=${CURRENT_VERSION#v}
77-
78-
case "${{ github.event.inputs.version_type }}" in
79-
"patch")
80-
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{printf "%d.%d.%d", $1, $2, $3+1}')
81-
;;
82-
"minor")
83-
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{printf "%d.%d.0", $1, $2+1}')
84-
;;
85-
"major")
86-
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{printf "%d.0.0", $1+1}')
87-
;;
88-
esac
89-
90-
echo "new_release_version=$NEW_VERSION" >> $GITHUB_OUTPUT
91-
echo "new_release_published=true" >> $GITHUB_OUTPUT
58+
# Automatic semantic release with error handling
59+
echo "Running automatic semantic release..."
60+
61+
# Try semantic-release, but handle PR-related failures gracefully
62+
if npx semantic-release --debug; then
63+
echo "✅ Semantic release completed successfully"
9264
93-
# Create the release in ITV/kics-github-action repository
94-
gh release create "v$NEW_VERSION" \
95-
--repo "ITV/kics-github-action" \
96-
--title "Release v$NEW_VERSION" \
97-
--notes "Manual release: ${{ github.event.inputs.version_type }} version bump" \
98-
--target main
65+
# Get the version that was created
66+
LATEST_TAG=$(gh release list --limit 1 | head -n 1 | awk '{print $1}')
67+
echo "🔍 Debug: Latest release tag from semantic-release: $LATEST_TAG"
68+
echo "new_release_version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
69+
echo "new_release_published=true" >> $GITHUB_OUTPUT
9970
else
100-
# Automatic semantic release with error handling
101-
echo "Running automatic semantic release..."
102-
103-
# Try semantic-release, but handle PR-related failures gracefully
104-
if npx semantic-release --debug; then
105-
echo "✅ Semantic release completed successfully"
106-
107-
# Get the version that was created
71+
SEMANTIC_EXIT_CODE=$?
72+
echo "⚠️ Semantic release failed with exit code: $SEMANTIC_EXIT_CODE"
73+
74+
# Check if this was a PR-related failure and the release was actually created
75+
if gh release list --limit 1 | head -n 1 | grep -q "v"; then
10876
LATEST_TAG=$(gh release list --limit 1 | head -n 1 | awk '{print $1}')
109-
echo "🔍 Debug: Latest release tag from semantic-release: $LATEST_TAG"
77+
echo "✅ Release $LATEST_TAG was created despite semantic-release error"
78+
echo "🔍 Debug: Latest release tag from fallback: $LATEST_TAG"
11079
echo "new_release_version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
11180
echo "new_release_published=true" >> $GITHUB_OUTPUT
11281
else
113-
SEMANTIC_EXIT_CODE=$?
114-
echo "⚠️ Semantic release failed with exit code: $SEMANTIC_EXIT_CODE"
115-
116-
# Check if this was a PR-related failure and the release was actually created
117-
if gh release list --limit 1 | head -n 1 | grep -q "v"; then
118-
LATEST_TAG=$(gh release list --limit 1 | head -n 1 | awk '{print $1}')
119-
echo "✅ Release $LATEST_TAG was created despite semantic-release error"
120-
echo "🔍 Debug: Latest release tag from fallback: $LATEST_TAG"
121-
echo "new_release_version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
122-
echo "new_release_published=true" >> $GITHUB_OUTPUT
123-
else
124-
echo "❌ No release was created"
125-
exit $SEMANTIC_EXIT_CODE
126-
fi
82+
echo "❌ No release was created"
83+
exit $SEMANTIC_EXIT_CODE
12784
fi
12885
fi
12986
@@ -156,18 +113,18 @@ jobs:
156113
run: |
157114
VERSION="${{ needs.release.outputs.version }}"
158115
echo "🔍 Debug: Received version from release job: '$VERSION'"
159-
116+
160117
if [ -z "$VERSION" ]; then
161118
echo "❌ Error: Version is empty!"
162119
exit 1
163120
fi
164-
121+
165122
echo "full=$VERSION" >> $GITHUB_OUTPUT
166123
167124
# Extract major, minor, patch
168125
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
169126
echo "🔍 Debug: Version components - MAJOR=$MAJOR, MINOR=$MINOR, PATCH=$PATCH"
170-
127+
171128
echo "major=$MAJOR" >> $GITHUB_OUTPUT
172129
echo "minor=$MINOR" >> $GITHUB_OUTPUT
173130
echo "patch=$PATCH" >> $GITHUB_OUTPUT
@@ -176,7 +133,7 @@ jobs:
176133
echo "major_tag=v$MAJOR" >> $GITHUB_OUTPUT
177134
echo "minor_tag=v$MAJOR.$MINOR" >> $GITHUB_OUTPUT
178135
echo "patch_tag=v$MAJOR.$MINOR.$PATCH" >> $GITHUB_OUTPUT
179-
136+
180137
echo "🔍 Debug: Generated tags - major_tag=v$MAJOR, minor_tag=v$MAJOR.$MINOR, patch_tag=v$MAJOR.$MINOR.$PATCH"
181138
182139
- name: Generate Docker metadata
@@ -231,27 +188,27 @@ jobs:
231188
run: |
232189
VERSION="${{ needs.release.outputs.version }}"
233190
echo "Creating mutable tags for version: $VERSION"
234-
191+
235192
# Extract version components
236193
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
237194
echo "Version components: MAJOR=$MAJOR, MINOR=$MINOR, PATCH=$PATCH"
238-
195+
239196
# Configure git
240197
git config user.name "github-actions[bot]"
241198
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
242-
199+
243200
# Create and push major version tag (v1, v2, etc.)
244201
echo "Creating major version tag: v$MAJOR"
245202
git tag -f "v$MAJOR"
246203
git push origin "v$MAJOR" --force
247204
echo "✅ Updated mutable tag v$MAJOR to point to v$VERSION"
248-
205+
249206
# Create and push minor version tag (v1.2, v1.3, etc.)
250207
echo "Creating minor version tag: v$MAJOR.$MINOR"
251208
git tag -f "v$MAJOR.$MINOR"
252209
git push origin "v$MAJOR.$MINOR" --force
253210
echo "✅ Updated mutable tag v$MAJOR.$MINOR to point to v$VERSION"
254-
211+
255212
# List all tags to verify
256213
echo "Current tags:"
257214
git tag --sort=-version:refname | head -10
@@ -282,4 +239,4 @@ jobs:
282239
# Use major version (gets latest compatible updates)
283240
uses: ITV/kics-github-action@v$(echo ${{ needs.release.outputs.version }} | cut -d. -f1)
284241
```
285-
EOF
242+
EOF

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ runs:
123123
IMAGE="ghcr.io/itv/kics-github-action:develop"
124124
fi
125125
echo "Using image: $IMAGE"
126+
126127
docker run --quiet --name kics-scan \
127128
-v "${{ github.workspace }}":"${{ github.workspace }}" \
129+
-v "${{ runner.temp }}":"${{ runner.temp }}" \
128130
-w "${{ github.workspace }}" \
129131
-e GITHUB_ACTION \
130132
-e GITHUB_ACTOR \

test/samples/positive1.tf

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/samples/positive2.tf

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)