This GitHub Action allows you to check the value of a variable and take action based on the value.
It can be used to check the value of a variable or the existence of a secret and use this information in a conditional statement to take different actions in a workflow.
- Check if an input variable is set (e.g. is not empty or undefined).
input
: (Required) The input value to check. It can be a string, a variable, or a secret (e.g.${{ secrets.MY_SECRET }}
).
has-value
: A boolean value indicating if the input has a value. It istrue
if the input is not empty or undefined, andfalse
otherwise.
- name: Check value
id: check-my-secret
uses: richardrigutins/check-value@v1
with:
input: ${{ secrets.MY_SECRET }}
- name: Use the output in a conditional statement
if: steps.check-my-secret.outputs.has-value == 'true'
run: echo "The secret has a value"
The src/
directory contains the source code that will be run when
the action is invoked.
After making changes to the action code, make sure to run the following command to run all tests, lint the code, and build the final JavaScript action code:
npm run all
This step is important! It will run
ncc
to build the final JavaScript action code with all dependencies included. If you do not run this step, the action will not work correctly when it is used in a workflow. This step also includes the--license
option forncc
, which will create a license file for all of the production node modules used in your project.
You can validate the action by referencing it in a test workflow file. For
example, ci.yml
demonstrates how to reference
this action in the same repository.
This project includes a helper script, script/release
designed to streamline the process of tagging and pushing new releases for
GitHub Actions.
GitHub Actions allows users to select a specific version of the action to use, based on release tags. This script simplifies this process by performing the following steps:
- Retrieving the latest release tag: The script starts by fetching the most recent release tag by looking at the local data available in your repository.
- Prompting for a new release tag: The user is then prompted to enter a new release tag. To assist with this, the script displays the latest release tag and provides a regular expression to validate the format of the new tag.
- Checking if the tag exists: The script checks if the tag already exists in the remote repository. If the tag already exists, the user is prompted to confirm if they want to overwrite the existing tag.
- Tagging the new release: Once a valid new tag is entered, the script tags the new release.
- Pushing the new tag to the remote: Finally, the script pushes the new tag to the remote repository. From here, you will need to create a new release in GitHub and users can easily reference the new tag in their workflows.
To use the script, run the following command:
./script/release
Contributions are welcome! Here are some ways you can contribute:
- Report bugs and suggest new features by creating an issue.
- Improve the documentation by submitting a pull request.
- Fix bugs or implement new features by submitting a pull request.
Before submitting a pull request, please make sure that your changes are consistent with the project's coding style and that all tests pass.