1

I am trying to get a private GitHub action to work within my private GitHub org. The private repo that contains these workflow 'templates' has this simple file structure as I'm just trying to get the bare minimum to work:

.
├── .git
├── test
│   ├── action.yml

And the action.yml file contents are:

name: Test

on: push

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:

    - name: Echo
      run: |
        echo Heyyyyy

I am trying to use this action in another private repo with a workflow file with these contents:

name: Test

on:
  push:
    branches:
      - master

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          repository: <private-actions-repo>
          token: ${{ secrets.REPO_TOKEN }}
          path: github-actions
      - name: Test private action
        uses: ./github-actions/test

When this action runs, I get the following error: ##[error]Top level 'runs:' section is required for /home/runner/work/<private-repo>/./github-actions/test/action.yaml

Trying to debug this, I updated the workflow that uses the template to cat the file contents of this file:

      - name: Test private action
        run: |
          cat ./github-actions/test/action.yml

..and I get the contents I would expect:

> Run cat ./github-actions/test/action.yml
name: Test

on: push

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:

    - name: Echo
      run: |
        echo Heyyyyy

Why would this not be working when using it from the action repo, but the exact same content works in the target repo?

riQQ
  • 9,878
  • 7
  • 49
  • 66
jrkt
  • 2,615
  • 5
  • 28
  • 48

2 Answers2

8

You have to differentiate between workflows, actions, and different action types.

Workflows are toplevel elements. Actions are building blocks that can be used in workflows. The action you defined in action.yml is actually a workflow but should be a composite run steps action, i.e. a specific type of action, that has to follow the rules given in: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions

You can find an example for a composite run steps action here: https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action#creating-an-action-metadata-file

If you use the following as action.yaml, it should work:

name: Test
description: 'composite run action'

runs:
  using: "composite"
  steps: 
    - name: Echo
      shell: bash
      run: |
        echo Heyyyyy
riQQ
  • 9,878
  • 7
  • 49
  • 66
0

My notes on confusing GitHub Actions terminology. I hope this clears things up.


  • Q: What is GitHub ActionS?
  • A: A CI/CD platform that allows the dev to automate builds, tests and deployments.

.

  • Q: What is a GitHub Workflow?
  • A: A workflow is a configurable automated process (i.e., on every push) that will run one or more jobs. They are defined in .github/workflows in the repo.

.

  • Q: What is a GitHub "Reusable" Worklfow?
  • A: A workflow that is referencing within another workflow.

.

  • Q: What is a GitHub Action?
  • A: An action is a custom application for the GitHub Actions platform that performs a complex but frequently repeated task. They are defined in .github/actions/<action_name>/action.yml in some repo.

.

  • Q: What is a GitHub "Composite" Action?
  • A: A composite action allows you to combine multiple workflow steps within one action.

E.g.,

name: Initialise the app environment

inputs:
  node-version:
    required: true
    type: string

runs:
  using: 'composite'
  steps:
    - name: Set up Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '${{ inputs.node-version }}'

    - name: Install dependencies
      shell: bash # ! the dev has to specify this line at every `run` step in a composite action
      run: npm install
Baran
  • 31
  • 3