Skip to content

Commit 800ae6d

Browse files
comments addressed
1 parent 4c26d3f commit 800ae6d

3 files changed

Lines changed: 65 additions & 9 deletions

File tree

.github/workflows/docker.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish docker image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: 'Tag to release'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
if: startsWith(github.event.inputs.release_tag, 'v')
19+
steps:
20+
- name: Harden the runner (Audit all outbound calls)
21+
uses: step-security/harden-runner@0v2
22+
with:
23+
egress-policy: audit
24+
25+
- name: Checkout
26+
uses: actions/checkout@v6
27+
- name: Validate tag format
28+
run: |
29+
TAG=${{ github.event.inputs.release_tag }}
30+
if ! echo "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
31+
echo "❌ Invalid tag format: $TAG"
32+
exit 1
33+
fi
34+
echo "✅ Valid semver tag: $TAG"
35+
- name: Log in to GitHub Container Registry
36+
uses: step-security/docker-login-action@v4
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Set up QEMU for ARM builds
43+
uses: step-security/setup-qemu-action@v4
44+
45+
- name: Set up Docker Buildx
46+
uses: step-security/setup-buildx-action@v4
47+
48+
- name: Build and push Docker image
49+
uses: step-security/docker-build-push-action@v7
50+
with:
51+
context: .
52+
push: true
53+
platforms: linux/amd64,linux/arm64
54+
tags: |
55+
ghcr.io/${{ github.repository }}:${{ github.event.inputs.release_tag }}

.github/workflows/pull-requests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
os: [ ubuntu-latest, macos-latest ]
24+
os: ${{ github.actor == 'dependabot[bot]' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest"]') }}
2525
runs-on: ${{ matrix.os }}
2626
steps:
2727
- uses: actions/checkout@v6
2828
- name: Set up Go
29-
uses: actions/setup-go@v5
29+
uses: actions/setup-go@v6
3030
with:
3131
go-version-file: 'go.mod'
3232
cache: true
@@ -39,7 +39,7 @@ jobs:
3939
steps:
4040
- uses: actions/checkout@v6
4141
- name: Set up Go
42-
uses: actions/setup-go@v5
42+
uses: actions/setup-go@v6
4343
with:
4444
go-version-file: 'go.mod'
4545
cache: true

main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@ func exitOnError(err error) {
5050
}
5151

5252
func validateSubscription() {
53-
eventPath := os.Getenv("GITHUB_EVENT_PATH")
54-
var repoPrivate *bool
53+
isPublic := false
5554

56-
if eventPath != "" {
55+
if eventPath := os.Getenv("GITHUB_EVENT_PATH"); eventPath != "" {
5756
if eventData, err := os.ReadFile(eventPath); err == nil {
5857
var event struct {
5958
Repository struct {
6059
Private *bool `json:"private"`
6160
} `json:"repository"`
6261
}
6362
if err := json.Unmarshal(eventData, &event); err == nil {
64-
repoPrivate = event.Repository.Private
63+
if event.Repository.Private != nil {
64+
isPublic = !*event.Repository.Private
65+
}
6566
}
6667
}
6768
}
@@ -73,13 +74,13 @@ func validateSubscription() {
7374
fmt.Println()
7475
fmt.Println("\x1b[1;36mStepSecurity Maintained Action\x1b[0m")
7576
fmt.Printf("Secure drop-in replacement for %s\n", upstream)
76-
if repoPrivate != nil && !*repoPrivate {
77+
if isPublic {
7778
fmt.Println("\x1b[32m\u2713 Free for public repositories\x1b[0m")
7879
}
7980
fmt.Printf("\x1b[36mLearn more:\x1b[0m %s\n", docsURL)
8081
fmt.Println()
8182

82-
if repoPrivate != nil && !*repoPrivate {
83+
if isPublic {
8384
return
8485
}
8586

0 commit comments

Comments
 (0)