Skip to content

Commit 8c7eda0

Browse files
committed
fix: absolute filepath
1 parent fc98acb commit 8c7eda0

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

.github/workflows/update_advisory.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ jobs:
2525
go-version: '1.21'
2626

2727
- name: Run Go application
28-
working-directory: ./src
2928
run: |
30-
go build -o ./src/update-advisory main.go
31-
./src/update-advisory
32-
rm ./src/update-advisory
29+
go build -o ./update-advisory main.go
30+
./update-advisory
31+
rm ./update-advisory
3332
3433
- name: Commit changes
3534
run: |

src/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"encoding/json"
2020
"fmt"
2121
"os"
22+
"path/filepath"
23+
"runtime"
2224
"strings"
2325
"time"
2426

@@ -63,7 +65,7 @@ var (
6365
now = time.Now()
6466
nowTimestamp = now.Format(time.RFC3339)
6567
today = format(now)
66-
policyPath = "./policies/V8-policy.json"
68+
policyPath = "policies/V8-policy.json"
6769
cachePath = "src/V8-cache.json"
6870
advisoryPath = "advisories/V8-advisory.json"
6971
)
@@ -110,7 +112,10 @@ func main() {
110112
}
111113

112114
func loadPolicy() (*Policy, error) {
113-
data, err := os.ReadFile(policyPath)
115+
_, filename, _, _ := runtime.Caller(0)
116+
dir := filepath.Dir(filename)
117+
advisoryFilePath := filepath.Join(dir, "../advisories/V8-advisory.json")
118+
data, err := os.ReadFile(advisoryFilePath)
114119
if err != nil {
115120
return nil, err
116121
}

0 commit comments

Comments
 (0)