Run callback on list of filenames
ActionsRuns a custom callback on a list of filenames (from either REF or PR number)
v1.0.1
LatestBy doximity
Tags
(1)Github action for running a callback after pulling the list of filenames belonging to either a Git REF (SHA1, tag or branch) or a pull request number.
- uses: doximity/[email protected]
with:
# Repository name with owner. For example, doximity/rake-ui
# Default: ${{ github.repository }}
repository: ''
# If using a PAT make sure to give it the "repo" scope.
# If using GITHUB_TOKEN make sure it's given the following permissions:
# contents: read
# pull-requests: read
#
# See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
#
# Default: ${{ github.token }}
token: ''
# The pull request number to pull the list of filenames from.
# When using this option you must not specify `ref`.
# NOTE: includes a maximum of 100 files.
pr_number: ''
# The branch, tag or SHA1 to pull the list of filenames from.
# When using this option you must not specify `pr_number`.
# NOTE: includes a maximum of 100 files.
ref: ''
# The function that will be passed a list of filenames and executed afterwards.
#
# It receives only one parameter, filenamesList, an array of filename strings
# which you can reference from your function's body.
#
# The return of your function is set as the `callback_return` output of this
# action, allowing you to reference that return value from other steps in your workflow.
#
# SECURITY WARNING: make sure you only reference trusted inputs from within the callback
# below. Because the code is `eval`'d this can pose a code injection risk if misused.
# Read more:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#understanding-the-risk-of-script-injections
#
# Default: return filenamesList
callback: ''
- List all filenames for a pull request
- List all filenames for master HEAD
- Use action's output from another step in a workflow
- uses: doximity/[email protected]
with:
repository: owner/repo
pr_number: 250
- uses: doximity/[email protected]
with:
repository: owner/repo
ref: master
- uses: doximity/[email protected]
id: check-for-graphql-changes
with:
repository: owner/repo
pr_number: 200
callback: |
return filenamesList.some((elem) => { return elem.match(/graphql/) })
- name: Run this step only if GraphQL changes are detected
if: ${{ steps.check-for-graphql-changes.outputs.callback_return == 'true' }}
run: |
echo "This PR includes GraphQL changes"
- Fork it and
git clone
it into your environment - Create your feature branch (
git checkout -b my-new-feature
) - Run
npm install
to install dependencies - Make your changes
- Ensure
npm run test
andnpm run lint
look good - Run
npm run dist
and commit the artifact - Create a Pull Request
- Sign the CLA if you haven't yet. See CONTRIBUTING
The behavior for this GH action is verified by two layers of testing:
- Unit:
npm run test
can be run locally and is also run on every push to a branch. Unit test coverage is a bit limited at the moment so contributions to improve it are more than welcome! - E2E: The actual action runs on every push to a branch which works as an E2E smoke test. See this workflow file for details.
The gem is available as open source under the terms of the Apache 2.0 License.
Run callback on list of filenames is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.