Skip to content

Commit 03e98f5

Browse files
authored
Harden CI workflows (#29)
* Harden GitHub Actions workflows - Pin every action ref to a full-length commit SHA with a trailing version comment, so floating tags like @v4 can't be re-pointed at malicious code. - Bump outdated actions/checkout@v1 to @v4.3.1 (where present). - Tag-triggered workflows now check out with fetch-depth: 1 and fetch-tags: true so the tag ref is available downstream. - release-tracker.yml grants contents: write at the job level so the default GITHUB_TOKEN can push commits/tags back to the repo. Signed-off-by: Tamal Saha <tamal@appscode.com> * Add job permissions for workflow Signed-off-by: Tamal Saha <tamal@appscode.com> * Normalize Prepare git user, fetch-depth, drop permission-issues Signed-off-by: Tamal Saha <tamal@appscode.com> * Add 1gtm-app[bot] to kodiak auto_approve_usernames Signed-off-by: Tamal Saha <tamal@appscode.com> * Normalize kodiak auto_approve_usernames Signed-off-by: Tamal Saha <tamal@appscode.com> * Bump softprops/action-gh-release to v2.6.2; add permissions Signed-off-by: Tamal Saha <tamal@appscode.com> * Makefile: use --tags in git describe so lightweight tags resolve Signed-off-by: Tamal Saha <tamal@appscode.com> * Remove bzr install from workflows Signed-off-by: Tamal Saha <tamal@appscode.com> * Makefile: use golangci-lint v1-compatible --skip-files flag Signed-off-by: Tamal Saha <tamal@appscode.com> --------- Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent eaef8a7 commit 03e98f5

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

‎.github/.kodiak.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ strip_html_comments = true # default: false
1515
always = true # default: false
1616

1717
[approve]
18-
auto_approve_usernames = ["1gtm", "tamalsaha"]
18+
auto_approve_usernames = ["tamalsaha", "1gtm", "1gtm-app[bot]"]

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@ jobs:
2020
runs-on: ubuntu-24.04
2121
steps:
2222
- name: Set up Go 1.19
23-
uses: actions/setup-go@v5
23+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
2424
with:
2525
go-version: 1.19
2626
id: go
2727

2828
- name: Check out code into the Go module directory
29-
uses: actions/checkout@v4
29+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
3030

3131
- name: Run checks
3232
run: |
33-
sudo apt-get -qq update || true
34-
sudo apt-get install -y bzr
3533
make ci

‎.github/workflows/release.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ jobs:
1414
build:
1515
name: Build
1616
runs-on: ubuntu-24.04
17+
permissions:
18+
contents: write
1719
steps:
1820

1921
- name: Check out code into the Go module directory
20-
uses: actions/checkout@v1
22+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
23+
with:
24+
fetch-depth: 0
2125

2226
- name: Print version info
2327
id: semver
@@ -26,12 +30,12 @@ jobs:
2630
2731
- name: Set up QEMU
2832
id: qemu
29-
uses: docker/setup-qemu-action@v3
33+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
3034
with:
3135
cache-image: false
3236

3337
- name: Set up Docker Buildx
34-
uses: docker/setup-buildx-action@v3
38+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
3539

3640
- name: Build
3741
env:
@@ -40,7 +44,7 @@ jobs:
4044
make release
4145
4246
- name: Release
43-
uses: softprops/action-gh-release@v1
47+
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
4448
if: startsWith(github.ref, 'refs/tags/')
4549
with:
4650
draft: true

‎Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ COMPRESS ?= no
2121

2222
# This version-strategy uses git tags to set the version string
2323
git_branch := $(shell git rev-parse --abbrev-ref HEAD)
24-
git_tag := $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")
24+
git_tag := $(shell git describe --tags --exact-match --abbrev=0 2>/dev/null || echo "")
2525
commit_hash := $(shell git rev-parse --verify HEAD)
2626
commit_timestamp := $(shell date --date="@$$(git show -s --format=%ct)" --utc +%FT%T)
2727

@@ -218,7 +218,7 @@ lint: $(BUILD_DIRS)
218218
--env GO111MODULE=on \
219219
--env GOFLAGS="-mod=vendor" \
220220
$(BUILD_IMAGE) \
221-
golangci-lint run --enable $(ADDTL_LINTERS) --timeout=20m --exclude-files="generated.*\.go$\" --exclude-dirs-use-default
221+
golangci-lint run --enable $(ADDTL_LINTERS) --timeout=20m --skip-files="generated.*\.go$\"
222222

223223
$(BUILD_DIRS):
224224
@mkdir -p $@

0 commit comments

Comments
 (0)