I have a github repo like this, files with same name have same content.
├── .github
│ ├── actions
│ │ └── hello-world
│ │ └── action.yml
│ └── workflows
│ └── main.yml
├── action.yml
└── goodbye.sh
The code in action.yml
given in follow, which is copied from official tutorial.
name: "Hello World"
description: "Greet to my little friend"
inputs:
who-to-greet:
description: "who to greet"
required: true
default: "World"
outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-number }}
runs:
using: "composite"
steps:
- run: echo Hello ${{ inputs.who-to-greet }}.
shell: bash
- id: random-number-generator
run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
shell: bash
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
- run: goodbye.sh
shell: bash
Then I try to use it in two different ways, first by {owner}/{repo}@{ref}
, second by ./path/to/dir
, however only second way can display random-number
normally. Why?
on:
push:
workflow_dispatch:
jobs:
hello_world:
runs-on: ubuntu-latest
name: say hello to my little firend
steps:
- uses: actions/checkout@v3
- id: foo
uses: chaoqunya/hello-world-composite-action@v1
with:
who-to-greet: "Chaos"
- run: echo random-number ${{ steps.foo.outputs.random-number }} test
shell: bash
- id: bar
uses: ./.github/actions/hello-world
with:
who-to-greet: "Chaos"
- run: echo random-number ${{ steps.bar.outputs.random-number }} test
shell: bash
CodePudding user response:
The first uses statement has @v1 attached to it, which means you are using the version from that tag.
Delete (including the remote!), recreate and push the tag again, or use @branch-name during testing.