Skip to content

Commit 7cf4612

Browse files
feat(sec): added process to auto-pin internal actions as well
1 parent b362e69 commit 7cf4612

5 files changed

Lines changed: 41 additions & 8 deletions

File tree

.github/workflows/create-release.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,39 @@ jobs:
3030
with:
3131
github_token: ${{ steps.app-token.outputs.token }}
3232

33+
- name: Checkout repository
34+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
35+
with:
36+
token: ${{ steps.app-token.outputs.token }}
37+
fetch-depth: 0
38+
39+
- name: Pin self reusable references to released SHA
40+
env:
41+
RELEASE_TAG: ${{ steps.tag_version.outputs.new_tag }}
42+
run: |
43+
set -euo pipefail
44+
45+
RELEASE_SHA="$(git rev-list -n 1 "$RELEASE_TAG")"
46+
echo "Pinning naviteq/github-actions reusable references to $RELEASE_SHA"
47+
48+
FILES=(
49+
".github/workflows/security-scan.yml"
50+
".github/workflows/helm-release-github.yaml"
51+
".github/workflows/helm-release-gar.yaml"
52+
".github/workflows/helm-release-ecr.yaml"
53+
)
54+
55+
for file in "${FILES[@]}"; do
56+
perl -i -pe "s#(uses:\\s+naviteq/github-actions/.+?)@[[:alnum:]._-]+#\$1@${RELEASE_SHA}#g" "$file"
57+
done
58+
59+
- name: Commit pinned self references
60+
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7
61+
with:
62+
branch: ${{ github.ref_name }}
63+
commit_message: "chore: pin self reusable references to ${{ steps.tag_version.outputs.new_tag }} SHA [skip ci]"
64+
file_pattern: ".github/workflows/security-scan.yml .github/workflows/helm-release-github.yaml .github/workflows/helm-release-gar.yaml .github/workflows/helm-release-ecr.yaml"
65+
3366
- name: Create a GitHub release
3467
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1
3568
with:

.github/workflows/helm-release-ecr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134

135135
- name: Run OCI core
136136
id: core
137-
uses: naviteq/github-actions/.github/actions/helm-release-oci@main
137+
uses: naviteq/github-actions/.github/actions/helm-release-oci@1782c15d239e5f8cd87e89706fd4be71a32f88fe
138138
with:
139139
chart_path: ${{ inputs.chart_path }}
140140
oci_registry: ${{ inputs.ecr_registry }}

.github/workflows/helm-release-gar.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ jobs:
139139

140140
- name: Run OCI core
141141
id: core
142-
uses: naviteq/github-actions/.github/actions/helm-release-oci@main
142+
uses: naviteq/github-actions/.github/actions/helm-release-oci@1782c15d239e5f8cd87e89706fd4be71a32f88fe
143143
with:
144144
chart_path: ${{ inputs.chart_path }}
145145
oci_registry: ${{ inputs.gar_registry }}

.github/workflows/helm-release-github.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jobs:
113113

114114
- name: Run OCI core
115115
id: core
116-
uses: naviteq/github-actions/.github/actions/helm-release-oci@main
116+
uses: naviteq/github-actions/.github/actions/helm-release-oci@1782c15d239e5f8cd87e89706fd4be71a32f88fe
117117
with:
118118
chart_path: ${{ inputs.chart_path }}
119119
oci_registry: ${{ inputs.ghcr_registry }}

.github/workflows/security-scan.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,27 @@ permissions:
9898
jobs:
9999
codeql:
100100
name: CodeQL
101-
uses: naviteq/github-actions/.github/workflows/security-codeql.yml@main
101+
uses: naviteq/github-actions/.github/workflows/security-codeql.yml@1782c15d239e5f8cd87e89706fd4be71a32f88fe
102102
with:
103103
RUNNER: ${{ inputs.codeql_runner != '' && inputs.codeql_runner || inputs.runner }}
104104
language: ${{ inputs.codeql_language }}
105105

106106
dependency-review:
107107
name: Dependency Review
108108
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' || github.event_name == 'merge_group' }}
109-
uses: naviteq/github-actions/.github/workflows/security-dependency-review.yml@main
109+
uses: naviteq/github-actions/.github/workflows/security-dependency-review.yml@1782c15d239e5f8cd87e89706fd4be71a32f88fe
110110
with:
111111
RUNNER: ${{ inputs.dependency_review_runner != '' && inputs.dependency_review_runner || inputs.runner }}
112112

113113
gitleaks:
114114
name: Gitleaks
115-
uses: naviteq/github-actions/.github/workflows/security-gitleaks.yml@main
115+
uses: naviteq/github-actions/.github/workflows/security-gitleaks.yml@1782c15d239e5f8cd87e89706fd4be71a32f88fe
116116
with:
117117
RUNNER: ${{ inputs.gitleaks_runner != '' && inputs.gitleaks_runner || inputs.runner }}
118118

119119
trivy:
120120
name: Trivy
121-
uses: naviteq/github-actions/.github/workflows/security-trivy.yml@main
121+
uses: naviteq/github-actions/.github/workflows/security-trivy.yml@1782c15d239e5f8cd87e89706fd4be71a32f88fe
122122
with:
123123
RUNNER: ${{ inputs.trivy_runner != '' && inputs.trivy_runner || inputs.runner }}
124124
scan_type: ${{ inputs.trivy_scan_type }}
@@ -131,7 +131,7 @@ jobs:
131131

132132
checkov:
133133
name: Checkov
134-
uses: naviteq/github-actions/.github/workflows/security-checkov.yaml@main
134+
uses: naviteq/github-actions/.github/workflows/security-checkov.yaml@1782c15d239e5f8cd87e89706fd4be71a32f88fe
135135
with:
136136
RUNNER: ${{ inputs.checkov_runner != '' && inputs.checkov_runner || inputs.runner }}
137137
directory: ${{ inputs.checkov_directory }}

0 commit comments

Comments
 (0)