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

Notify when there was no commited changes #46

Closed
piranna opened this issue Feb 27, 2020 · 8 comments
Closed

Notify when there was no commited changes #46

piranna opened this issue Feb 27, 2020 · 8 comments
Labels
enhancement New feature or request on hold

Comments

@piranna
Copy link

piranna commented Feb 27, 2020

At

echo "Working tree clean. Nothing to commit."
, if there's no content to commit, the action exit sucessfully, but there's no way to know if there were commited changes or repo is untouched. I need to know this to prevent to publish a package to npm with nightly changes if there has been no changes. Ideally Github Actions should provide a neutral output as it did in legacy version, but it got removed. Maybe one alternative would be to set an environment variable to notify this.

@stefanzweifel
Copy link
Owner

I think there are a couple of things we could do here:

  • Add a new input option which will indicate that the Action should fail if no changes were committed (through the exit code).
  • Push a value to the Actions output. Your workflow could then interact with the value and stop the publishing process.

I personally like both approaches.

@piranna
Copy link
Author

piranna commented Feb 28, 2020

I was thinking about both ideas, and I like both of them, too. Problem with the exit code is that you would not be able to diferenciate when it failed or it was a neutral exit, probably would be the less bad of the cases.

What do you mean about "push a value to the Actions output"? Some trick like Azure one to set environment variables between steps, where they are echoed to stdout with a special prefix? Do you have documentation about that?

@stefanzweifel
Copy link
Owner

What do you mean about "push a value to the Actions output"?

I thought about adding this: https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions#outputs

We could do something like this

echo \"::set-output name=changed_detected::true\"
echo \"::set-output name=changed_detected::false\"

You would then have access to the value in your workflow file through steps.<step_id>.outputs.tag.


As an example, this repository has a workflow, which automatically creates a new release, when a tag is pushed.
The workflow uses the output of one Action or step in another step.

steps:
- name: "Determine tag"
id: "determine-tag"
run: "echo \"::set-output name=tag::${GITHUB_REF#refs/tags/}\""
- name: "Create release"
uses: "actions/[email protected]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
draft: false
prerelease: false
release_name: "${{ steps.determine-tag.outputs.tag }}"
tag_name: "${{ steps.determine-tag.outputs.tag }}"

@stefanzweifel stefanzweifel added the enhancement New feature or request label Feb 28, 2020
@piranna
Copy link
Author

piranna commented Feb 28, 2020

What do you mean about "push a value to the Actions output"?

I thought about adding this: help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions#outputs

We could do something like this

echo \"::set-output name=changed_detected::true\"
echo \"::set-output name=changed_detected::false\"

You would then have access to the value in your workflow file through steps.<step_id>.outputs.tag.

It's almost equal to how Azure does it :-) This fine for me :-)

@stefanzweifel
Copy link
Owner

@piranna Just a head up: I've prepared something in #49 and merged it into master. I'm probably gonna release a proper version in the upcoming days, as I would like to add #47 to 4.1.0as well.

You will then be able to use the output like this:
https://github.com/stefanzweifel/git-auto-commit-action/blob/956a47433ba7e7968b6b72ee72f9e4ca4e8ca2a2/.github/workflows/git-auto-commit.yml

Will close this issue when I've tagged a new version.

@piranna
Copy link
Author

piranna commented Mar 4, 2020

I'm probably gonna release a proper version in the upcoming days, as I would like to add #47 to 4.1.0as well

Great, that would be useful to me too :-) I'm willing to use that feature at nightly pipelines of https://github.com/projectlint/OS-lifecycle :-)

@stefanzweifel
Copy link
Owner

Hello again,

I've just released v4.1.0 which has the changes made in #49 in it.

https://github.com/stefanzweifel/git-auto-commit-action/releases/tag/v4.1.0

Hope you can utilise this in your workflows.

@piranna
Copy link
Author

piranna commented Mar 6, 2020

Hope you can utilise this in your workflows.

Nice, now it's working :-)

https://github.com/projectlint/OS-lifecycle/runs/490127931?check_suite_focus=true

Thank you so much! :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request on hold
Projects
None yet
Development

No branches or pull requests

2 participants