Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No step output is being generated #323

Closed
ChristianVermeulen opened this issue Mar 15, 2024 · 4 comments
Closed

No step output is being generated #323

ChristianVermeulen opened this issue Mar 15, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@ChristianVermeulen
Copy link
Contributor

ChristianVermeulen commented Mar 15, 2024

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

  • Run the autocommit and make sure it has something to commit
  • Run a next step with if: steps.auto-commit-action.outputs.changes_detected == 'true'

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.

@ChristianVermeulen ChristianVermeulen added the bug Something isn't working label Mar 15, 2024
@stefanzweifel
Copy link
Owner

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
Copy link
Contributor Author

@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
Copy link
Owner

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

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

@ChristianVermeulen
Copy link
Contributor Author

Ready for review in #324. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants