wip: add support for reading env from CI
This commit is contained in:
parent
a2abeaee2f
commit
860a633e11
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@ -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
|
||||
|
||||
21
cmd/github/githubactions.go
Normal file
21
cmd/github/githubactions.go
Normal 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
|
||||
}
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user