Skip to content

Commit c2c7888

Browse files
committed
chore/security: clean using best practices
1 parent 3405ff6 commit c2c7888

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
name: build image on release
2+
23
on:
34
workflow_dispatch:
45
release:
56
types: [published]
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
security-events: write
12+
613
jobs:
714
extract-release-info:
815
runs-on: ubuntu-latest
@@ -26,24 +33,25 @@ jobs:
2633
VERSION="${BASH_REMATCH[2]}"
2734
echo "Extracted project: $PROJECT, version: $VERSION"
2835
else
29-
echo "Invalid release name format. Expected: 'project-version'"
36+
echo "::error::Invalid release name format. Expected: 'project-version'"
37+
echo "::error::Received: '$RELEASE_NAME'"
3038
exit 1
3139
fi
3240
3341
CONFIG_FILE=".github/config/build-matrices.yaml"
3442
3543
# Check if project exists in YAML
3644
if ! yq eval ".projects | has(\"$PROJECT\")" "$CONFIG_FILE" | grep -q "true"; then
37-
echo "Project '$PROJECT' is not configured!"
38-
echo "Available projects:"
45+
echo "::error::Project '$PROJECT' is not configured!"
46+
echo "::notice::Available projects:"
3947
yq eval '.projects | keys | .[]' "$CONFIG_FILE" | sed 's/^/ - /'
4048
exit 1
4149
fi
4250
4351
# Validate version format (semantic versioning)
4452
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?([-][A-Za-z0-9\.]+)*$ ]]; then
45-
echo "Invalid version format: $VERSION"
46-
echo "Expected semantic versioning format (e.g., 1.2.3, 1.2.3-beta)"
53+
echo "::error::Invalid version format: $VERSION"
54+
echo "::notice::Expected semantic versioning format (e.g., 1.2.3, 1.2.3-beta)"
4755
exit 1
4856
fi
4957
@@ -53,7 +61,7 @@ jobs:
5361
INCLUDE_ARRAY=$(yq eval ".projects.${PROJECT}.include" "$CONFIG_FILE" -o=json -I=0)
5462
5563
if [[ "$INCLUDE_ARRAY" == "null" ]]; then
56-
echo "No include configuration found for project '$PROJECT'!"
64+
echo "::error::No include configuration found for project '$PROJECT'!"
5765
exit 1
5866
fi
5967
@@ -71,12 +79,6 @@ jobs:
7179
- name: Checkout
7280
uses: actions/checkout@v5
7381

74-
- name: Set up JDK
75-
uses: actions/setup-java@v5
76-
with:
77-
java-version: '21'
78-
distribution: 'temurin'
79-
8082
- name: Set up Docker Buildx
8183
uses: docker/setup-buildx-action@v3
8284

@@ -98,7 +100,7 @@ jobs:
98100
continue-on-error: true
99101
uses: aquasecurity/trivy-action@0.33.1
100102
with:
101-
image-ref: 'ghcr.io/${{ github.repository_owner }}/${{ matrix.tag }}:${{ needs.extract-release-info.outputs.version }}'
103+
image-ref: ghcr.io/${{ github.repository_owner }}/${{ matrix.tag }}:${{ needs.extract-release-info.outputs.version }}
102104
format: 'sarif'
103105
output: 'trivy-${{ matrix.name }}-image.sarif'
104106
severity: 'HIGH,CRITICAL'
@@ -117,4 +119,4 @@ jobs:
117119
with:
118120
name: ${{ matrix.artifact-name }}
119121
path: '*.sarif'
120-
retention-days: 7
122+
retention-days: 30

0 commit comments

Comments
 (0)