Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
list

GitHub Action

Get Organization Repository Names

v2

Get Organization Repository Names

list

Get Organization Repository Names

Get all an organization's repository names to do matrix builds

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Get Organization Repository Names

uses: austenstone/get-org-repos@v2

Learn more about this action in austenstone/get-org-repos

Choose a version

Get Organization's Repositories

This is an Action to list all an orgnization's repositories.

There primary use case is for repeating a task for all the repositories in an organization.

Default Workflow

name: Hello World

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  get-org-repos:
    name: Get Repos
    runs-on: ubuntu-latest
    steps:
      - uses: austenstone/get-org-repos@main
        with:
          github-token: ${{ secrets.GH_TOKEN }}
        id: get-org-repos
    outputs:
      repos: ${{ steps.get-org-repos.outputs.repos }}

  print:
    name: Print Repo
    needs: [get-org-repos]
    runs-on: ubuntu-latest
    strategy:
      matrix:
        repo: ${{ fromJson(needs.get-org-repos.outputs.repos) }}
      fail-fast: false
    steps:
      - name: Print
        run: echo "Hello ${{ matrix.repo }}!"

Git Workflow

name: Sync Repositories

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  get-org-repos:
    runs-on: ubuntu-latest
    steps:
      - uses: austenstone/get-org-repos@main
        with:
          github-token: ${{ secrets.GH_TOKEN }}
        id: get-org-repos
    outputs:
      repos: ${{ steps.get-org-repos.outputs.repos }}

  sync:
    needs:
      - get-org-repos
    runs-on: ubuntu-latest
    strategy:
      matrix:
        repo: ${{ fromJson(needs.get-org-repos.outputs.repos) }}
      fail-fast: false
    steps:
      - uses: actions/checkout@v3
        with:
          repository: ${{ github.event.organization.login }}/${{ matrix.repo }}
          token: ${{ secrets.GH_TOKEN }}
      - run: |
          git config --global user.name 'github-actions'
          git config --global user.email '[email protected]'
      - run: git remote add source https://github.com/${{ github.event.organization.login }}/${{ github.event.repository.name }}
      - run: git fetch source
      - run: git merge --allow-unrelated-histories --squash -X ours source/main
      - run: git remote remove source
      - run: |
          for fileName in .github/workflows/sync.yml README.md; do
            git reset HEAD -- $fileName
            git clean -f -q -- $fileName
          done 
      - run: git diff-index --quiet HEAD || git commit -am "Organization sync"
      - run: git push

➡️ Input Settings

Various inputs are defined in action.yml:

Name Description Default
github‑token Token to use to authorize. ${{ github.token }}
org The organization name. ${{ github.event.organization.login }}

Further help

To get more help on the Actions see documentation.