Skip to content

Commit ecf118b

Browse files
authored
Merge pull request #3039 from Nordix/harden-github-workflow
🌱Harden GitHub workflow
2 parents 1e8ca5f + 0c9fccb commit ecf118b

File tree

8 files changed

+22
-8
lines changed

8 files changed

+22
-8
lines changed

.github/workflows/pr-dependabot.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
steps:
2222
- name: Check out code into the Go module directory
2323
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
24+
with:
25+
persist-credentials: false
2426
- name: Calculate go version
2527
id: vars
2628
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT

.github/workflows/pr-gh-workflow-approve.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
name: Approve GH Workflows
66

77
on:
8-
pull_request_target:
8+
pull_request_target: # zizmor: ignore[dangerous-triggers]
99
types: [ opened, edited, reopened, synchronize, ready_for_review ]
1010

1111
permissions: {}

.github/workflows/pr-link-check.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
fetch-depth: 0
2222
ref: ${{github.event.pull_request.head.ref}}
2323
repository: ${{github.event.pull_request.head.repo.full_name}}
24+
persist-credentials: false
2425

2526
- name: Add upstream remote
2627
run: |

.github/workflows/pr-verifer.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Check PR Title
22
permissions: {}
33

44
on:
5-
pull_request_target:
5+
pull_request:
66
types: [ opened, edited, reopened, synchronize, ready_for_review ]
77

88
jobs:
@@ -11,6 +11,8 @@ jobs:
1111
steps:
1212
- name: Check out repository
1313
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
14+
with:
15+
persist-credentials: false
1416

1517
- name: Validate PR Title
1618
env:

.github/workflows/release.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@ jobs:
2323
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
2424
with:
2525
fetch-depth: 0
26+
persist-credentials: false
2627
- name: Get changed files
2728
id: changed-files
2829
uses: tj-actions/changed-files@7dee1b0c1557f278e5c7dc244927139d78c0e22a # v47.0.4
2930
- name: Get release version
3031
id: release-version
32+
env:
33+
STEPS_CHANGED_FILES_OUTPUTS_ALL_CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
34+
STEPS_CHANGED_FILES_OUTPUTS_ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
3135
run: |
32-
if [[ ${{ steps.changed-files.outputs.all_changed_files_count }} != 1 ]]; then
33-
echo "1 release notes file should be changed to create a release tag, found ${{ steps.changed-files.outputs.all_changed_files_count }}"
36+
if [[ "${STEPS_CHANGED_FILES_OUTPUTS_ALL_CHANGED_FILES_COUNT}" != "1" ]]; then
37+
echo "1 release notes file should be changed to create a release tag, found ${STEPS_CHANGED_FILES_OUTPUTS_ALL_CHANGED_FILES_COUNT}"
3438
exit 1
3539
fi
36-
for changed_file in ${{ steps.changed-files.outputs.all_changed_files }}; do
40+
for changed_file in ${STEPS_CHANGED_FILES_OUTPUTS_ALL_CHANGED_FILES}; do
3741
export RELEASE_VERSION=$(echo "${changed_file}" | grep -oP '(?<=/)[^/]+(?=\.md)')
3842
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> ${GITHUB_ENV}
3943
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> ${GITHUB_OUTPUT}
@@ -94,6 +98,7 @@ jobs:
9498
with:
9599
fetch-depth: 0
96100
ref: ${{ env.RELEASE_TAG }}
101+
persist-credentials: false
97102
- name: Calculate go version
98103
run: echo "go_version=$(make go-version)" >> ${GITHUB_ENV}
99104
- name: Set up Go
@@ -107,8 +112,8 @@ jobs:
107112
GH_TOKEN: ${{ github.token }}
108113
- name: get release notes
109114
run: |
110-
curl -L "https://raw.githubusercontent.com/${{ github.repository }}/main/releasenotes/${{ env.RELEASE_TAG }}.md" \
111-
-o "${{ env.RELEASE_TAG }}.md"
115+
curl -fsSL "https://raw.githubusercontent.com/${{ github.repository }}/main/releasenotes/${RELEASE_TAG}.md" \
116+
-o "${RELEASE_TAG}.md"
112117
- name: Release
113118
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # tag=v2.5.0
114119
with:

.github/workflows/security-scan.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
2222
with:
2323
ref: ${{ matrix.branch }}
24+
persist-credentials: false
2425
- name: Calculate go version
2526
id: vars
2627
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT

.github/workflows/update-golangci-lint.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ jobs:
2121
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2222
with:
2323
fetch-depth: 0
24+
persist-credentials: false
2425
- name: Get latest golangci-lint version
2526
id: get_version
2627
run: |
27-
export LATEST_VERSION=$(curl -s https://api.github.com/repos/golangci/golangci-lint/releases/latest | jq -r .tag_name)
28+
export LATEST_VERSION=$(curl -fsSL https://api.github.com/repos/golangci/golangci-lint/releases/latest | jq -r .tag_name)
2829
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV
2930
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_OUTPUT
3031
- name: Check current version in Makefile

.github/workflows/yamllint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
run: sudo apt-get update && sudo apt-get install -y yamllint
1616

1717
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
with:
19+
persist-credentials: false
1820

1921
- name: yaml-lint
2022
run: yamllint -c .yamllint.yaml .

0 commit comments

Comments
 (0)