Skip to content

Commit e4b90da

Browse files
authored
Harden CI workflows (#84)
* 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> --------- Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 65e04ff commit e4b90da

4 files changed

Lines changed: 12 additions & 8 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
runs-on: ubuntu-24.04
2020
steps:
2121
- name: Set up Go 1.25
22-
uses: actions/setup-go@v5
22+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
2323
with:
2424
go-version: '1.25'
2525
id: go
2626

2727
- name: Check out code into the Go module directory
28-
uses: actions/checkout@v4
28+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
2929

3030
- name: Run checks
3131
run: |

.github/workflows/release.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ jobs:
1414
build:
1515
name: Build
1616
runs-on: ubuntu-24.04
17+
permissions:
18+
contents: write
1719
steps:
1820
- name: Check out code into the Go module directory
19-
uses: actions/checkout@v1
21+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
22+
with:
23+
fetch-depth: 0
2024

2125
- name: Print version info
2226
id: semver
@@ -25,12 +29,12 @@ jobs:
2529
2630
- name: Set up QEMU
2731
id: qemu
28-
uses: docker/setup-qemu-action@v3
32+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
2933
with:
3034
cache-image: false
3135

3236
- name: Set up Docker Buildx
33-
uses: docker/setup-buildx-action@v3
37+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
3438

3539
- name: Build
3640
env:
@@ -39,7 +43,7 @@ jobs:
3943
make release
4044
4145
- name: Release
42-
uses: softprops/action-gh-release@v1
46+
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
4347
if: startsWith(github.ref, 'refs/tags/')
4448
with:
4549
files: |

Makefile

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)