File tree Expand file tree Collapse file tree 3 files changed +40
-23
lines changed
Expand file tree Collapse file tree 3 files changed +40
-23
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ jobs:
1111 runs-on : ubuntu-latest
1212 env :
1313 actor : ${{ github.actor }}
14+ base_ref : ${{ github.base_ref }}
15+ head_ref : ${{ github.head_ref }}
1416 steps :
1517 - name : Check out code
1618 uses : actions/checkout@v4
17- - name : Feeling cute. Might (aka should) delete later
18- run : git branch --show-current
1919 - name : Set up Go
2020 uses : actions/setup-go@v5
2121 with :
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+ "errors"
7+ "fmt"
8+ "os"
9+ )
10+
11+ const (
12+ actionsActorKey = "actor"
13+ actionsBaseRefKey = "base_ref"
14+ actionsHeadRefKey = "head_ref"
15+ )
16+
17+ // ActionsActor returns the username of the GitHub user who triggered the
18+ // current CI run as part of GitHub Actions. The value must be loaded into the
19+ // env as part of the Github Actions YAML file, or else the function fails.
20+ func ActionsActor () (string , error ) {
21+ username := os .Getenv (actionsActorKey )
22+ if username == "" {
23+ return "" , fmt .Errorf ("value for %q is not in env. Please update the CI script to load the value in during CI" , actionsActorKey )
24+ }
25+ return username , nil
26+ }
27+
28+ // ActionsRefs returns the name of the head ref and the base ref for current CI
29+ // run, in that order. Both values must be loaded into the env as part of the
30+ // GitHub Actions YAML file, or else the function fails.
31+ func ActionsRefs () (string , string , error ) {
32+ baseRef := os .Getenv (actionsBaseRefKey )
33+ headRef := os .Getenv (actionsHeadRefKey )
34+ fmt .Println ("Base ref: " , baseRef )
35+ fmt .Println ("Head ref: " , headRef )
36+
37+ return "" , "" , errors .New ("we ain't ready yet" )
38+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments