Can't get input value.
notanops opened this issue · 1 comments
Hi,
I'm barely new to Github action and try to make your awesome project work. I tried to make it as simple as possible.
First, I have a repo with my Go code which contains a Go project, simple main.go (and go.mod / go.sum). Here is my main, pretty straightforward, similar as your project's README. It takes an input and set a time value as output.
package main
import (
"fmt"
"time"
"github.com/sethvargo/go-githubactions"
)
func main() {
user := githubactions.GetInput("who")
fmt.Printf("User : %s\n", user)
time := time.Now()
githubactions.SetOutput("time", time.String())
fmt.Printf("Time : %s", time)
}
In the same repo I have an action.yml file which describe how to run it :
name: "Say hello"
description: "Github Action to say hello"
inputs:
who:
description: 'User to say hello'
required: true
outputs:
time:
description: 'The time we said hello'
runs:
using: composite
steps:
- name: Build
working-directory: src/
run: go build -o ../bin/main
shell: bash
- name: Run
working-directory: bin/
run: ./main
shell: bash
In another repo I try to make it works with a workflow file like this :
name: Go
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Checkout code action
uses: actions/checkout@v2
with:
repository: me/myrepo
- name: Go example
uses: me/myrepo@main
with:
who: 'John Doe'
All steps run fine, but "who" input can't be retrieved.
Here are the logs for Go example build step :
Run me/repo@main
Run go build -o ../bin/main
go: downloading github.com/sethvargo/go-githubactions v1.1.0
go: downloading github.com/sethvargo/go-envconfig v0.8.0
Run ./main
User :
Time : 2023-01-27 08:15:35.300536781 +0000 UTC m=+0.000578302
Output is nicely set but I can't figure out why user is empty.
Inputs in composite actions are only available via the YAML syntax inputs.who-to-greet
- they are not passed into the actual process. You can see this if you look at the value of the environment (env
) inside the job.