From a1144d86f26b0216bda6047f0a0732f3a16f2bf8 Mon Sep 17 00:00:00 2001 From: Or Elimelech Date: Tue, 22 Oct 2024 15:47:01 +0300 Subject: [PATCH] chore: set default values and fix permissions --- .github/workflows/ci.yaml | 5 ++++- build/main.go | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5ee3657..4d8a5c7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,6 +4,8 @@ on: [push] jobs: pipeline: runs-on: ubuntu-latest + permissions: + packages: write steps: - name: Checkout uses: actions/checkout@v4 @@ -14,4 +16,5 @@ jobs: - name: Dagger pipeline run: go run ./build - + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build/main.go b/build/main.go index 5725a2e..2d0443a 100644 --- a/build/main.go +++ b/build/main.go @@ -1,6 +1,7 @@ package main import ( + "cmp" "context" "flag" "fmt" @@ -37,10 +38,10 @@ func Task(name string) func(ctr *dagger.Container) *dagger.Container { } func Publish(ctx context.Context, dag *dagger.Client, ctr *dagger.Container) (string, error) { - user := os.Getenv("GITHUB_ACTOR") + user := cmp.Or(os.Getenv("GITHUB_ACTOR"), "github-actions") pass := dag.SetSecret("GITHUB_TOKEN", os.Getenv("GITHUB_TOKEN")) registry := "ghcr.io" - image := fmt.Sprintf("%s/%s", registry, os.Getenv("GITHUB_REPOSITORY")) + image := fmt.Sprintf("%s/%s", registry, cmp.Or(os.Getenv("GITHUB_REPOSITORY"), "bufile")) return dag.Container(). From("gcr.io/distroless/static"). WithFile("/bufile", ctr.File("/src/bufile")).