wip: add support for reading env from CI

This commit is contained in:
Michael Smith 2025-04-14 18:09:43 +00:00
parent a2abeaee2f
commit 860a633e11
3 changed files with 31 additions and 0 deletions

View File

@ -9,6 +9,8 @@ concurrency:
jobs:
validate-contributors:
runs-on: ubuntu-latest
env:
actor: ${{ github.actor }}
steps:
- name: Check out code
uses: actions/checkout@v4

View File

@ -0,0 +1,21 @@
// Package github provides utilities to make it easier to deal with various
// GitHub APIs
package github
import (
"fmt"
"os"
)
const envActorUsernameKey = "actor"
// ActionsActor returns the username of the GitHub user who triggered the
// current CI run as part of GitHub Actions.The value must be loaded into the
// env as part of the Github Actions script file, or else the function fails.
func ActionsActor() (string, error) {
username := os.Getenv(envActorUsernameKey)
if username == "" {
return "", fmt.Errorf("value for %q is not in env. Please update the CI script to load the value in during CI", envActorUsernameKey)
}
return username, nil
}

View File

@ -8,9 +8,17 @@ package main
import (
"log"
"coder.com/coder-registry/cmd/github"
)
func main() {
username, err := github.ActionsActor()
if err != nil {
log.Panic(err)
}
log.Println("running as %q", username)
log.Println("Starting README validation")
allReadmeFiles, err := aggregateContributorReadmeFiles()
if err != nil {