stefanzweifel / git-auto-commit-action

Automatically commit and push changed files back to GitHub with this GitHub Action for the 80% use case.
MIT License
1.92k stars 224 forks source link

No step output is being generated #323

Closed ChristianVermeulen closed 4 months ago

ChristianVermeulen commented 4 months ago

git-auto-commit Version

V5

Machine Type

Ubuntu (eg. ubuntu-latest)

Bug description

When trying to use the output in order to place a comment on the PR, the next step is never triggered because there is no output.

Steps to reproduce

The next step will not run.

Tried solutions

No response

Example Workflow

      - uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: Autofixed your phpscs for ya
          commit_user_name: christianvermeulen
          commit_user_email: christian.vermeulen@******.be
          commit_author: christianvermeulen <christian.vermeulen@******.be>

      - name: Notify PR owner
        if: steps.auto-commit-action.outputs.changes_detected == 'true'
        uses: thollander/actions-comment-pull-request@v2
        with:
          message: |
            Hey @${{ github.event.pull_request.head.repo.owner.login }}, I've taken the liberty to fix your CS (${{steps.auto-commit-action.outputs.commit_hash}}). Don't forget to pull before you push new commit!

Relevant log output

I added a debug step to echo all steps output like so:

      - uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: Autofixed your phpscs for ya
          commit_user_name: christianvermeulen
          commit_user_email: christian.vermeulen@******.be
          commit_author: christianvermeulen <christian.vermeulen@******.be>

      - name: debug
        run: |
          echo "${{ toJson(steps) }}"

      - name: Notify PR owner
        if: steps.auto-commit-action.outputs.changes_detected == 'true'
        uses: thollander/actions-comment-pull-request@v2
        with:
          message: |
            Hey @${{ github.event.pull_request.head.repo.owner.login }}, I've taken the liberty to fix your CS (${{steps.auto-commit-action.outputs.commit_hash}}). Don't forget to pull before you push new commit!

The output of that json is as follows:

{
    "composer-cache": {
      "outputs": {
        "{DIR}": "{/home/runner/.cache/composer/files}"
      },
      "outcome": "success",
      "conclusion": "success"
    }
  }

As you can see, there is no output from the auto-commit job, only from a different composer-cache job.

stefanzweifel commented 4 months ago

Thanks for reporting @ChristianVermeulen.

Looks like a documentation error on my side. When you want to read the output of a workflow step, you need to give that step an explicit ID. That's something we currently don't mention in the README.

Could you add an id of "auto-commit-action" to your workflow like this?

      - uses: stefanzweifel/git-auto-commit-action@v5
+       id: auto-commit-action
        with:
          commit_message: Autofixed your phpscs for ya
          commit_user_name: christianvermeulen
          commit_user_email: christian.vermeulen@******.be
          commit_author: christianvermeulen <christian.vermeulen@******.be>

      - name: Notify PR owner
        if: steps.auto-commit-action.outputs.changes_detected == 'true'
        uses: thollander/actions-comment-pull-request@v2
        with:
          message: |
            Hey @${{ github.event.pull_request.head.repo.owner.login }}, I've taken the liberty to fix your CS (${{steps.auto-commit-action.outputs.commit_hash}}). Don't forget to pull before you push new commit!

This should fix the issue.

ChristianVermeulen commented 4 months ago

@stefanzweifel Ah, that was it indeed! I did not know that about the GH Action 😅 Thanks for answering so quick!

Would you like me to do a quick PR to add it in the docs?

stefanzweifel commented 4 months ago

@ChristianVermeulen Feel free to send in a PR. ♥️

It probably makes sense to expand the example in the README here.

ChristianVermeulen commented 4 months ago

Ready for review in #324. Thanks again!