|
| 1 | +--- |
| 2 | +name: Update Repositories List in Roadmap |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + organizations: |
| 8 | + description: 'GitHub organizations to fetch repositories from (comma-separated)' |
| 9 | + required: true |
| 10 | + default: 'LizardByte,LizardByte-infrastructure' |
| 11 | + schedule: |
| 12 | + - cron: '0 0 * * *' |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - master |
| 16 | + types: |
| 17 | + - opened |
| 18 | + - reopened |
| 19 | + - synchronize |
| 20 | + paths: |
| 21 | + - '.github/ISSUE_TEMPLATE/roadmap.yml' |
| 22 | + push: |
| 23 | + branches: |
| 24 | + - master |
| 25 | + paths: |
| 26 | + - '.github/workflows/update_issue_templates.yml' |
| 27 | + |
| 28 | +jobs: |
| 29 | + update-repositories: |
| 30 | + name: Update Repository List |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Get organizations |
| 37 | + id: get_orgs |
| 38 | + run: | |
| 39 | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
| 40 | + ORGS="${{ github.event.inputs.organizations }}" |
| 41 | + else |
| 42 | + ORGS="LizardByte,LizardByte-infrastructure" # Default organizations |
| 43 | + fi |
| 44 | + echo "orgs=$ORGS" >> $GITHUB_OUTPUT |
| 45 | + echo "Organizations to process: $ORGS" |
| 46 | +
|
| 47 | + - name: Fetch repositories |
| 48 | + id: fetch_repos |
| 49 | + uses: actions/github-script@v7 |
| 50 | + with: |
| 51 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + script: | |
| 53 | + const orgs = '${{ steps.get_orgs.outputs.orgs }}'.split(',').map(org => org.trim()); |
| 54 | + let allRepos = []; |
| 55 | +
|
| 56 | + for (const org of orgs) { |
| 57 | + console.log(`Fetching repositories for organization: ${org}`); |
| 58 | +
|
| 59 | + const opts = github.rest.repos.listForOrg.endpoint.merge({ |
| 60 | + org: org |
| 61 | + }); |
| 62 | +
|
| 63 | + const repos = await github.paginate(opts); |
| 64 | +
|
| 65 | + const activeRepos = repos |
| 66 | + .filter(repo => !repo.archived && !repo.disabled) |
| 67 | + .map(repo => repo.name); |
| 68 | +
|
| 69 | + allRepos = [...allRepos, ...activeRepos]; |
| 70 | + } |
| 71 | +
|
| 72 | + // Sort repositories alphabetically |
| 73 | + allRepos.sort(); |
| 74 | +
|
| 75 | + console.log(`Found ${allRepos.length} repositories across ${orgs.length} organization(s)`); |
| 76 | + return allRepos; |
| 77 | +
|
| 78 | + - name: Update repositories dropdown |
| 79 | + id: update_dropdown |
| 80 | + |
| 81 | + with: |
| 82 | + form: .github/ISSUE_TEMPLATE/roadmap.yml |
| 83 | + dropdown: repositories |
| 84 | + options: ${{ steps.fetch_repos.outputs.result }} |
| 85 | + dry_run: no-push |
| 86 | + |
| 87 | + - name: Git Diff |
| 88 | + if: github.event_name == 'pull_request' |
| 89 | + run: git diff |
| 90 | + |
| 91 | + - name: Create/Update Pull Request |
| 92 | + if: github.event_name != 'pull_request' |
| 93 | + uses: peter-evans/create-pull-request@v7 |
| 94 | + with: |
| 95 | + add-paths: | |
| 96 | + .github/ISSUE_TEMPLATE/*.yml |
| 97 | + token: ${{ secrets.GH_BOT_TOKEN }} |
| 98 | + commit-message: "chore: Update repositories list in roadmap.yml" |
| 99 | + branch: bot/update-repositories-list |
| 100 | + delete-branch: true |
| 101 | + title: "chore: Update repositories list in roadmap.yml" |
| 102 | + body: | |
| 103 | + This PR updates the list of repositories in the roadmap issue template. |
| 104 | + The list was automatically generated by a GitHub Action. |
| 105 | + labels: | |
| 106 | + auto-approve |
| 107 | + auto-merge |
0 commit comments