githubgithub-actionsrepositorycicd

How to Publish Multiple GitHub Actions from a Single Repo and Call Them from Another Repo


I am trying to publish multiple GitHub Actions from a single repository to the GitHub Marketplace and use them in other repositories. My repo structure looks like this:

.
├── transform-openapi-from-file/
│   ├── action.yml
│   ├── script.sh
├── update-collection/
│   ├── action.yml
│   ├── script.sh

Here's my repo: https://github.com/stcalica/postman-publish-action

I’ve successfully created individual actions with their own action.yml files. However, I’m struggling with two things:

  1. Publishing Multiple Actions to the GitHub Marketplace: I understand how to publish a single action, but how do I publish multiple actions from the same repository to GitHub Marketplace? Each action has its own subdirectory and action.yml file, but I can't seem to find clear guidance on publishing them both under one repo.

  2. Calling These Actions from Another Repo: In my other repository, I want to use these actions. When I try to reference the action like this:

    - name: Generate Schema
      uses: stcalica/transform-openapi-from-file@v1
      with:
        postman_api_key: ${{ secrets.POSTMAN_API_KEY }}
        openapi_schema: ${{ vars.OPEN_API_SCHEMA }}
    

    I get an error:

    Error: Unable to resolve action `stcalica/transform-openapi-from-file@v1`, unable to find version `v1`
    

I’ve tried specifying the full path to the subdirectory in the uses section, but the action still doesn’t seem to be found. What is the correct way to reference actions located in subdirectories from another public repo?

Any help on:

  1. Publishing multiple actions from one repository to GitHub Marketplace.
  2. Properly referencing these actions in another repository.

I tried to make a repo and call it like this:

name: Test Postman Schema Publish 

on:
  workflow_dispatch:

jobs:
  schema-publish-update:
    runs-on: ubuntu-latest
    env:
      POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
  
      - name: Generate Schema 
        uses: stcalica/postman-publish-action/transform-openapi-from-file@main
        id: schema
        with:
          postman_api_key: ${{ secrets.POSTMAN_API_KEY }}
          openapi_filepath: './cats.yaml'

Solution

  • You can't publish multiple actions from the same repository; from the docs:

    Actions are published to GitHub Marketplace immediately and aren't reviewed by GitHub as long as they meet these requirements:

    • The action must be in a public repository.
    • Each repository must contain a single action.
    • [...]

    However, that doesn't prevent anybody from using the actions; they just don't show up in the marketplace.

    As for referencing an action in a subdirectory, what you show is correct. As long as the action exists in the main branch of the postman-publish-action repo in the transform-openapi-from-file directory, this should run it:

    uses: stcalica/postman-publish-action/transform-openapi-from-file@main
    

    I can see in your repo that you have an actions subdirectory, so really the path should be

    uses: stcalica/postman-publish-action/actions/transform-openapi-from-file@main
    #                                    ^^^^^^^^