Skip to content

Uses step in Composite Action #25778

Uses step in Composite Action #25778
May 21, 2021 · 9 answers

I am trying to build a Composite action. In that I am trying to use another action with “uses” statement. But I am getting an error when I try to call this composite action from a workflow.- “Unexpected value ‘uses’”. Can’t we call another action from within a composite action? Couldn’t find it in documentation also.

Composite Actions can only be created using run steps. They are only designed to chain together multiple “run” steps. Creating a composite run steps action - GitHub Docs

Replies

9 suggested answers

Composite Actions can only be created using run steps. They are only designed to chain together multiple “run” steps. Creating a composite run steps action - GitHub Docs

0 replies
Answer selected

Thank you. Unfortunately, the documentation doesn’t state what is supported & not supported. This is the reason for the confusion.

0 replies

Are there any plans to support use in composite actions? Without those, they’re just another way of writing a bash script 😦

0 replies

There is some ongoing work:

  <a href="https://github.com/actions/runner/pull/1144" target="_blank" rel="noopener">github.com/actions/runner</a>

Composite Actions Support ADR

<div class="branches">
  <code>actions:main</code> ← <code>actions:thboop/CompositeAdr</code>
</div>

<div class="github-info">
  <div class="date">
    opened <span class="discourse-local-date" data-format="ll" data-date="2021-06-10" data-time="21:41:30" data-timezone="UTC">09:41PM - 10 Jun 21 UTC</span>
  </div>

  <div class="user">
    <a href="https://github.com/thboop" target="_blank" rel="noopener">
      <img alt="thboop" src="https://user-images.githubusercontent.com/5814919/181093242-b0fa58b5-a3db-464f-ad4d-cd580cf88dc1.jpeg" class="onebox-avatar-inline" width="20" height="20">
      thboop
    </a>
  </div>

  <div class="lines" title="3 commits changed 1 files with 94 additions and 0 deletions">
    <a href="https://github.com/actions/runner/pull/1144/files" target="_blank" rel="noopener">
      <span class="added">+94</span>
      <span class="removed">-0</span>
    </a>
  </div>
</div>

[Rendered](https://github.com/actions/runner/blob/4d7988e0ad30584f7c61d8b669a6babf04d0e486/docs/adrs/0000-composite-actions.md) We welcome community feedback, please feel free to comment on this ADR!

This ADR outlines the next steps we are taking to change composite run steps into composite actions, and specifically mentions how certain scenarios will work.

I haven’t seen anything about when we can expect this to become available, though.

0 replies

Shocking amounts of code duplication because this isn’t a feature

0 replies

According to the Metadata Syntax documentation, under the section for "runs for composite actions," composite actions allow the use of uses. See here: Metadata syntax for GitHub Actions - GitHub Docs

Is this a recent change, or is the documentation incorrect?

If the documentation is correct and this works now, I’m still not able to get it working. I’m seeing Unexpected value 'uses' errors. (for example, here: run actions on all pushes · ramsey/composer-install@793876b · GitHub)


The documentation shows examples like this:

runs:
  using: "composite"
  steps:
    # Reference a specific commit
    - uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675
    # Reference the major version of a release
    - uses: actions/checkout@v2
    # Reference a specific version
    - uses: actions/checkout@v2.2.0
    # Reference a branch
    - uses: actions/checkout@main
    # References a subdirectory in a public GitHub repository at a specific branch, ref, or SHA
    - uses: actions/aws/ec2@main
    # References a local action
    - uses: ./.github/actions/my-action
    # References a docker public registry action
    - uses: docker://gcr.io/cloud-builders/gradle
    # Reference a docker image published on docker hub
    - uses: docker://alpine:3.8

and this:

runs:
  using: "composite"
  steps:
    - name: My first step
      uses: actions/hello_world@main
      with:
        first_name: Mona
        middle_name: The
        last_name: Octocat  
0 replies

After some trial-and-error, I got uses working with composite actions. They were failing because I was specifying working-directory. Once I removed that, they work.

0 replies
ramsey:

Is this a recent change, or is the documentation incorrect?

Sort of recent, as in August, about one month after the last post in this thread before yours. 😉

  <a href="https://github.blog/changelog/2021-08-25-github-actions-reduce-duplication-with-action-composition/" target="_blank" rel="noopener">The GitHub Blog</a>

GitHub Actions: Reduce duplication with action composition | GitHub Changelog

GitHub Actions: Reduce duplication with action composition

Est. reading time: 1 minute

0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants