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.97k stars 226 forks source link

Commit if there are file by pattern in the commit itself #175

Closed Mte90 closed 2 years ago

Mte90 commented 2 years ago

Is your feature request related to a problem? Please describe. It is not clear by the action if can do that check, in our case we need to check the commit as we need to generate some pdf and reupload it. The issue is that it there will a timestamp so the files will be different also if they aren't after all and we don't want to commit with this files.

Our idea was to check if the commit include files of a pattern/folder included in this way the action can be execute to push the changes.

stefanzweifel commented 2 years ago

The file_pattern is used in the "is dirty"-check and determines if files should be added and committed (see code); so I think what you want to do should work.

I think examples make everything easier. If I understood you correctly, your workflow looks something like this:

# other code related to when workflow is triggered

-   run: /execute/some/code

-   uses: stefanzweifel/git-auto-commit-action@v4
    id: auto-commit-action
    with:
        file_pattern: src/*.js

-   name: "Generate PDFs if previously a commit has been created"
    if: steps.auto-commit-action.outputs.changes_detected == 'true'
    run: /generate/pdfs

-   name: "Commit generated PDFs"
    if: steps.auto-commit-action.outputs.changes_detected == 'true'
    uses: stefanzweifel/git-auto-commit-action@v4
    with:
        file_pattern: src/*.pdf
        commit_message: "Add auto generated PDFs"

If not, could you please share more information of what you want to achieve here?

Mte90 commented 2 years ago

Seems perfect, I wasn't sure if I can mention twice the action as the examples mention only once. Infact I was thinking what is the need to check only after executing the action and executing again just for push it.

stefanzweifel commented 2 years ago

You could even use the Action trice or 16 times in a workflow. :)

Infact I was thinking what is the need to check only after executing the action and executing again just for push it.

Thats a question you have to answer for yourself as it depends on what you want to achieve in your workflow.

I close this issue now, as I think your primary question has been answered. Feel free to create a new discussion thread, if you have another question.