File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ concurrency:
99jobs :
1010 validate-contributors :
1111 runs-on : ubuntu-latest
12+ env :
13+ actor : ${{ github.actor }}
1214 steps :
1315 - name : Check out code
1416 uses : actions/checkout@v4
Original file line number Diff line number Diff line change 1+ // Package github provides utilities to make it easier to deal with various
2+ // GitHub APIs
3+ package github
4+
5+ import (
6+ "fmt"
7+ "os"
8+ )
9+
10+ const envActorUsernameKey = "actor"
11+
12+ // ActionsActor returns the username of the GitHub user who triggered the
13+ // current CI run as part of GitHub Actions.The value must be loaded into the
14+ // env as part of the Github Actions script file, or else the function fails.
15+ func ActionsActor () (string , error ) {
16+ username := os .Getenv (envActorUsernameKey )
17+ if username == "" {
18+ return "" , fmt .Errorf ("value for %q is not in env. Please update the CI script to load the value in during CI" , envActorUsernameKey )
19+ }
20+ return username , nil
21+ }
Original file line number Diff line number Diff line change @@ -8,9 +8,17 @@ package main
88
99import (
1010 "log"
11+
12+ "coder.com/coder-registry/cmd/github"
1113)
1214
1315func main () {
16+ username , err := github .ActionsActor ()
17+ if err != nil {
18+ log .Panic (err )
19+ }
20+ log .Println ("running as %q" , username )
21+
1422 log .Println ("Starting README validation" )
1523 allReadmeFiles , err := aggregateContributorReadmeFiles ()
1624 if err != nil {
You can’t perform that action at this time.
0 commit comments