|
| 1 | +# This workflow needs to be run on demand |
| 2 | +# It will update all workflow templates in all repositories of the organization |
| 3 | +# This workflow is provided via the organization template repository |
| 4 | +# |
| 5 | +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors |
| 6 | +# SPDX-License-Identifier: MIT |
| 7 | +name: Update workflows for all repositories |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | +jobs: |
| 14 | + get-repos: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + name: Get all repositories in the organization |
| 17 | + outputs: |
| 18 | + repositories: ${{ steps.get-repos.outputs.repositories }} |
| 19 | + steps: |
| 20 | + - name: Check actor permission |
| 21 | + uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0 |
| 22 | + with: |
| 23 | + require: admin |
| 24 | + |
| 25 | + - name: Get all repositories |
| 26 | + id: get-repos |
| 27 | + env: |
| 28 | + GH_TOKEN: ${{ secrets.TEMPLATE_WORKFLOW_DISPATCH_PAT }} |
| 29 | + run: | |
| 30 | + repositories=$(gh api \ |
| 31 | + --paginate \ |
| 32 | + --jq '[.[] | {name: .name, branch: .default_branch}]' \ |
| 33 | + orgs/${{ github.repository_owner }}/repos \ |
| 34 | + | jq -sc 'add') |
| 35 | + echo "repositories=$repositories" >> $GITHUB_OUTPUT |
| 36 | +
|
| 37 | + dispatch: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + needs: get-repos |
| 40 | + name: Update all workflows in ${{ matrix.repository.name }} |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + repository: ${{ fromJson(needs.get-repos.outputs.repositories) }} |
| 45 | + steps: |
| 46 | + - name: Dispatch update workflow |
| 47 | + env: |
| 48 | + GH_TOKEN: ${{ secrets.TEMPLATE_WORKFLOW_DISPATCH_PAT }} |
| 49 | + run: | |
| 50 | + gh workflow run dispatch-workflow-repo.yml \ |
| 51 | + --repo ${{ github.repository }} \ |
| 52 | + --field repository=${{ matrix.repository.name }} \ |
| 53 | + --field branch=${{ matrix.repository.branch }} |
0 commit comments