GitHub Actions: Execute a script file without checkout

Just starting with GitHub Actions. Is there a way of bundling script files to be referenced and executed as part of a Step without checking out the repo?

steps:
  - name: Run Script
    shell: bash
    run: ./my-script.sh

Not as script files, no, you’ll only have access to that after checkout. What’s the issue with checking out the repository?

Two possible alternatives, but not exactly what you’re asking for:

  1. Include the script directly in the run block, if it’s not too big.
steps:
  - name: Run Script
    shell: bash
    run: |
      ls this/
      echo "that"
  1. Set up and use an Action that runs your script (probably a Docker or Composite action). Not that running an action implicitly checks out the action repository, but in that case you can keep the script in the action repository.

Thanks. I was exploring GitHub Actions capabilities and I have a workflow that builds, tests and pushes a docker image to a registry. Then I have another workflow that deploys a container on a remote host based on a tag (don’t want to deploy it on every change to a branch). Since the image is already in the registry I have no need to checkout the repo to produce the image. In case of big repo (for example) just seemed a bit wasteful to checkout. The reasoning was also to keep the workflow declaration small and concise by pushing the logic onto script files. I understand there are alternatives, like a dedicated repo or a custom Action.

1 Like