Skip to content

Github Actions: Custom Actions#

Actions checkout location in workflow#

Actions are automatically checked out by Github Action from the beginning of a workflow run, the checkout path could be found by: env var $GITHUB_ACTION_PATH, github context ${{ github.action_path }}. This is very useful when you need to reference some files or scripts saved in the same repository as the actions.


Actions in workflow:

- name: Check out repository code
  uses: actions/checkout@v4

- name: Use action in the version of the main branch

- name: Use action in the version of v1

Actions checkout location:

├── v4
   ├── ...

├── main
   └── actions
   └── ...
├── main.completed
├── v1
   └── actions
   └── ...
└── v1.completed

Multiple actions in single repository#

You can save multiple actions inside a single repository, and use them in the form of uses: org/repo/folder_path@git_ref in a workflow.


Benefits of using azure/CLI over run task:

  1. azure/CLI runs az commands in an isolated docker container.
  2. azure/CLI can choose the CLI version.
  3. For some self-hosted runner, may not have "az cli" pre-installed, the Azure/CLI action eliminates the need for complex installation steps.

Can also set shared variables inside a job to be used outside the azure/CLI step, even it's run inside a docker container.


  1. slowness: azure/CLI is much slower (around 20s to bootstrap on a ubuntu-latest-4core runner) than standard run step, because it needs to pull the docker image and run the container.