You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
Get Organization Repository Names
v2
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.
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 }}!"
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
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 }} |
To get more help on the Actions see documentation.