pascalgn / npm-publish-action

GitHub action to automatically publish packages to npm
MIT License
221 stars 29 forks source link

Add context output after run #37

Closed GreenDjango closed 3 years ago

GreenDjango commented 3 years ago

PR for #20 issue

Add outputs context like version-check repo.

Outputs

To access these outputs, you need to access the context of the step you previously set up: you can find more info about steps contexts here.
If you set your step id to check you'll find the outputs at steps.check.outputs.OUTPUT_NAME: you can use these outputs as conditions for other steps.
Here's an example:

- name: Publish if version has been updated
  id: check
  uses: pascalgn/npm-publish-action@f6302932be3d13d292168d31a9ea193c717567ff
              # This is tagged version v1.3.7, but do not use version tags
              # https://julienrenaux.fr/2019/12/20/github-actions-security-risk/

- name: Log when changed
  if: steps.check.outputs.changed == 'true'
  run: 'echo "Version change found in commit ${{ steps.check.outputs.commit }}! New version: ${{ steps.check.outputs.version }}"'

- name: Log when unchanged
  if: steps.check.outputs.changed == 'false'
  run: 'echo "No version change :/"'
pascalgn commented 3 years ago

Thanks for the PR, it's merged now! 👍