Skip to content

πŸ—„οΈ Get organization or user repos based on the topics filter (with logic AND/OR) to use in the matrix job or another action.

License

Notifications You must be signed in to change notification settings

raven-actions/get-repos

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—„οΈ Get Repositories Action

GitHub - marketplace GitHub - release GitHub - ci GitHub - license

This GitHub Action provides a list of repositories associated with a provided organization or user, with the option to include specific topics related to the repositories.

The primary purpose is to repeat a task for all repositories in an organization using the GitHub Actions matrix feature. It's the default behavior with json array output.

⚠️ With a job matrix, creating a maximum of 256 jobs per workflow run is possible!

You can also use this action to get a flat output with your delimiter for different purposes than the matrix job. Read more in the Flat output section.

πŸ“ƒ Table of Contents

πŸ€” Usage

Quick Start

Example GitHub Workflow, to get all repositories that contain ANY of listed topics (OR operator is by default). Follow πŸ“₯ Inputs to adjust behavior to AND. Then the result will be: get all repos with ALL listed topics.

name: Sync Repositories

on:
  schedule:
    - cron: "30 6 * * *"

jobs:
  get-repos:
    name: Get Repos
    runs-on: ubuntu-latest
    outputs:
      repos: ${{ steps.get-repos.outputs.repos }}
    steps:
      - name: Get Repositories Action
        id: get-repos
        uses: raven-actions/get-repos@v1
        with:
          topics: "sync,docs,managed"

  sync-repos:
    name: Sync (${{ matrix.repo.name }})
    if: ${{ needs.get-repos.outputs.repos != '[]' }} # make sure repos exist
    runs-on: ubuntu-latest
    needs:
      - get-repos
    strategy:
      matrix:
        repo: ${{ fromJson(needs.get-repos.outputs.repos) }}
      fail-fast: false
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          repository: ${{ matrix.repo.full_name }}

      # rest of your workflow steps...

Flat output

- name: Get Repositories Action (flat)
  id: get-repos
  uses: raven-actions/get-repos@v1
  with:
    topics: "raven-actions,composite-action"
    operator: AND  # logic operator for topics match, AND returns repos that have all of provided topics, OR is default
    format: flat
    delimiter: ","  # default one is '\n'

- name: Repos
  run: |
    echo "Total count: ${COUNT}"
    echo "Format: ${FORMAT}"
    echo "Repos:"
    echo "${REPOS}"
  env:
    REPOS: ${{ steps.get-repos.outputs.repos }}
    COUNT: ${{ steps.get-repos.outputs.count }}
    FORMAT: ${{ steps.get-repos.outputs.format }}

πŸ“₯ Inputs

Name Required Type Default value Description
owner false string github.repository_owner The organization or user name
topics false string not set Comma-separated list of repository topics
operator false string OR Logic operator to use when filtering repositories by topics, OR or AND
matrix-use false bool true Output to be used in matrix job? It just checks that the returned query has not exceeded 256 repos
format false string json Output format, json or flat, default to json
delimiter false string \n Delimiter to use when format is flat, default to \n
github-token false string github.token GitHub Token with repo scope. Be aware results are always limited to permissions of GitHub tokens

πŸ“€ Outputs

Name Type Description
repos json / string Repositories (JSON array object if format is set to json / string if format is set to flat)
count int Number of found repositories
format string Output format

Example JSON output

Each of the keys you can use in your matrix job.

[
  {
    "owner": "raven-actions",
    "name": "debug",
    "full_name": "raven-actions/debug",
    "private": false,
    "html_url": "https://github.com/raven-actions/debug",
    "fork": false,
    "archived": false,
    "disabled": false,
    "is_template": false,
    "visibility": "public",
    "default_branch": "main"
  },
  {
    "owner": "raven-actions",
    "name": "actionlint",
    "full_name": "raven-actions/actionlint",
    "private": false,
    "html_url": "https://github.com/raven-actions/actionlint",
    "fork": false,
    "archived": false,
    "disabled": false,
    "is_template": false,
    "visibility": "public",
    "default_branch": "main"
  }
]

Example FLAT output

The flat output with the custom delimiter ,:

raven-actions/debug,raven-actions/actionlint

Flat output returns always full name! owner/repo

πŸ‘₯ Contributing

Contributions to the project are welcome! Please follow Contributing Guide.

πŸ“„ License

This project is distributed under the terms of the MIT license.