Skip to content

Commit

Permalink
Set 0444 specifically for the github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Marin Dzhigarov committed Jan 10, 2025
1 parent 4ed5964 commit a883f6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/compile-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
steps:

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.22.0
go-version: 1.22.1
id: go

- name: Check out code into the Go module directory
Expand Down
9 changes: 8 additions & 1 deletion testing/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ import (
// WriteKeys copies the static private key in variable privateKey
// to a local file.
func WriteKeys(rootPath string) error {
isGitHubActions := os.Getenv("GITHUB_ACTIONS") == "true"
var keyPerm os.FileMode
if isGitHubActions {
keyPerm = 0444 // Use 0444 if running in GitHub Actions
} else {
keyPerm = 0600 // Use 0600 if not running in GitHub Actions (default case)
}
pkPath := filepath.Join(rootPath, "id_rsa")
pkFile, err := os.OpenFile(pkPath, os.O_RDWR|os.O_CREATE, 0600)
pkFile, err := os.OpenFile(pkPath, os.O_RDWR|os.O_CREATE, keyPerm)
if err != nil {
return err
}
Expand Down

0 comments on commit a883f6f

Please sign in to comment.