I'm fairly new-ish to GitHub Actions and I'm trying to figure out the difference between 2 ways to use the same custom action.
Say we have a basic action node-install-ci
that contains the following files: Dockerfile
, action.yml
, entrypoint.sh
. (Where the Dockerfile
and action.yml
just point to entrypoint.sh
as the action entrypoint.)
I've seen a similar action used in 2 different ways in the same code-base:
jobs:
# ...
steps:
- name: Install
# either direct access
run: ./.github/actions/node-install-ci/entrypoint.sh
# or through docker
uses: ./.github/actions/node-install-ci
Obviously using the uses
keyword will make GitHub Actions go through the Dockerfile
(and run in a container?), whereas the direct access just runs the entrypoint directly in the current environment.
What I'm wondering is whether this difference in usage matters and could lead to unintended consequences for Actions that are more complex than npm ci
?
Honestly, I'm surprised that running an install action through docker even works to begin with.
I guess I kind of knew the answer when I posted this; obviously the difference is whether or not your GitHub Action needs Docker or the action.yml file.
If your action is so simple that you really only need to run a single shell script, then I'd say it's fine/equivalent to use - run: ./.github/actions/your_action/entrypoint.sh
. But if your action is complex (i.e. needs docker, or some extra features of action.yml) then running the entrypoint directly could skip out on some critical setup or tangential actions that would be achieved using - uses: ./.github/actions/your_action
.
Ultimately, it is up to you and your knowledge of the functionality of your custom action to determine whether these 2 different ways to run a GitHub Action will have different results.