Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub actions splitting workflow file

Is it possible to split a GitHub Actions workflow file and reference it from other? I need to deploy an application into multiple environments i.e. staging and production and would like to share half of the steps to minimize maintenance.

like image 730
Sohail Ahmed Avatar asked Jun 20 '26 20:06

Sohail Ahmed


1 Answers

You can split each action in the following file format:

folder named "test-action"

.github/test-action/action.yml

with contents

  name: test-action
  description: test action
  inputs:
    test_input:
      description: key
      required: true
  runs:
    using: composite
    steps:
      - name: echo test
        shell: bash
        run: |
          echo ${{inputs.test_input}}

then you can refer to the action from any yml:

  - name: test-action
    uses: ./.github/test-action
    with:
      test_input: "test-string-value"

the key here was to make sure that the file within your named action folder would be called "action.yml"

like image 164
Carl M. Cartagena Avatar answered Jun 23 '26 19:06

Carl M. Cartagena



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!