CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2023-09-26
by Krzysztof Madej

Original Post

Original - Posted on 2023-02-18
by rickstaa



            
Present in both answers; Present only in the new answer; Present only in the old answer;

I don't know how your composite actions looks so for this
``` name: 'Hello World' description: 'Greet someone' inputs: who-to-greet: # id of input description: 'Who to greet' required: true default: 'World' outputs: random-number: description: "Random number" value: ${{ steps.random-number-generator.outputs.random-number }} random-number-bash: description: "Random number bash" value: ${{ steps.random-number-generator-bash.outputs.random-number-bash }} 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 ```
and this workflow
``` jobs: hello_world_job: runs-on: ubuntu-latest name: A job to say hello outputs: foo: ${{ steps.foo.outputs.random-number }} steps: - uses: actions/checkout@v3 - id: foo uses: ./.github/actions/hello-world-composite-action-output with: who-to-greet: 'Mona the Octocat' - run: echo random-number ${{ steps.foo.outputs.random-number }} shell: bash job2: runs-on: ubuntu-latest needs: hello_world_job steps: - env: OUTPUT1: ${{needs.hello_world_job.outputs.foo}} run: echo "$OUTPUT1" ```
I got
[![enter image description here][1]][1]
and this is available in subsequent job:
[![enter image description here][2]][2]

[1]: https://i.stack.imgur.com/HEQEO.png [2]: https://i.stack.imgur.com/8dCIk.png
I found my issue using [@benjamin-w][1]'s comment. The problem was that the `goodbye.sh` step should contain an `id` key for the created output to be referenced correctly. The correct syntax should be:
**action.yml**
```yml name: 'Hello World' description: 'Greet someone' inputs: who-to-greet: # id of input description: 'Who to greet' required: true default: 'World' outputs: random-number: description: "Random number" value: ${{ steps.random-number-generator.outputs.random-number }} random-number-bash: description: "Random number bash" value: ${{ steps.random-number-generator-bash.outputs.random-number-bash }} 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 id: random-number-generator-bash shell: bash ``` And the correct syntax for creating the output in the `goodbye.sh` script should be:
**Goodbye.sh**
```bash echo "Goodbye" echo "random-number-bash=$(echo 123)" >> $GITHUB_OUTPUT ```
Which then can be tested using the following workflow file:
**Test workflow**
```yml on: [push]
jobs: hello_world_job: runs-on: ubuntu-latest name: A job to say hello steps: - uses: actions/checkout@v3 - id: foo uses: rickstaa/hello-world-composite-action-output-bug@main with: who-to-greet: 'Mona the Octocat' - run: echo random-number ${{ steps.foo.outputs.random-number }} shell: bash - run: echo random-number ${{ steps.foo.outputs.random-number-bash }} shell: bash ```

[1]: https://stackoverflow.com/users/3266847/benjamin-w

        
Present in both answers; Present only in the new answer; Present only in the old answer;