test: try logging refs
This commit is contained in:
parent
ec1b4a72cb
commit
0a597c23f4
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -11,11 +11,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
actor: ${{ github.actor }}
|
||||
base_ref: ${{ github.base_ref }}
|
||||
head_ref: ${{ github.head_ref }}
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
- name: Feeling cute. Might (aka should) delete later
|
||||
run: git branch --show-current
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
|
||||
38
cmd/github/github.go
Normal file
38
cmd/github/github.go
Normal file
@ -0,0 +1,38 @@
|
||||
// Package github provides utilities to make it easier to deal with various
|
||||
// GitHub APIs
|
||||
package github
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
actionsActorKey = "actor"
|
||||
actionsBaseRefKey = "base_ref"
|
||||
actionsHeadRefKey = "head_ref"
|
||||
)
|
||||
|
||||
// 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 YAML file, or else the function fails.
|
||||
func ActionsActor() (string, error) {
|
||||
username := os.Getenv(actionsActorKey)
|
||||
if username == "" {
|
||||
return "", fmt.Errorf("value for %q is not in env. Please update the CI script to load the value in during CI", actionsActorKey)
|
||||
}
|
||||
return username, nil
|
||||
}
|
||||
|
||||
// ActionsRefs returns the name of the head ref and the base ref for current CI
|
||||
// run, in that order. Both values must be loaded into the env as part of the
|
||||
// GitHub Actions YAML file, or else the function fails.
|
||||
func ActionsRefs() (string, string, error) {
|
||||
baseRef := os.Getenv(actionsBaseRefKey)
|
||||
headRef := os.Getenv(actionsHeadRefKey)
|
||||
fmt.Println("Base ref: ", baseRef)
|
||||
fmt.Println("Head ref: ", headRef)
|
||||
|
||||
return "", "", errors.New("we ain't ready yet")
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user