generated from LizardByte/template-base
-
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (115 loc) · 4.17 KB
/
update_issue_templates.yml
File metadata and controls
130 lines (115 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
name: Update Repositories List in Roadmap
permissions:
contents: read
on:
workflow_dispatch:
inputs:
organizations:
description: 'GitHub organizations to fetch repositories from (comma-separated)'
required: true
default: 'LizardByte,LizardByte-infrastructure'
schedule:
- cron: '0 0 * * *'
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
push:
branches:
- master
jobs:
update-repositories:
name: Update Repository List
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Get organizations
id: get_orgs
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
ORGS="${{ github.event.inputs.organizations }}"
else
ORGS="LizardByte,LizardByte-infrastructure" # Default organizations
fi
echo "orgs=$ORGS" >> "${GITHUB_OUTPUT}"
echo "Organizations to process: $ORGS"
- name: Fetch repositories
id: fetch_repos
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const orgs = '${{ steps.get_orgs.outputs.orgs }}'.split(',').map(org => org.trim());
let allRepos = [];
for (const org of orgs) {
try {
console.log(`Fetching repositories for organization: ${org}`);
const opts = github.rest.repos.listForOrg.endpoint.merge({
org: org
});
const repos = await github.paginate(opts);
console.log(`Successfully fetched ${repos.length} repositories from ${org}`);
const activeRepos = repos
.filter(repo => !repo.archived)
.map(repo => `${org}/${repo.name}`);
console.log(`Found ${activeRepos.length} active repositories for ${org}`);
allRepos = [...allRepos, ...activeRepos];
} catch (error) {
console.error(`Error fetching repositories for organization ${org}:`, error);
throw new Error(`Failed to fetch repositories for organization ${org}`);
}
}
// Sort repositories alphabetically
allRepos.sort();
console.log(`Found ${allRepos.length} repositories across ${orgs.length} organization(s)`);
return allRepos;
- name: Update repositories dropdown
id: update_dropdown
uses: ShaMan123/gha-form-dropdown-options@v2.1.0
with:
form: .github/ISSUE_TEMPLATE/roadmap.yml
template: .github/t_roadmap.yml
dropdown: _repositories
options: ${{ steps.fetch_repos.outputs.result }}
dry_run: no-commit
- name: git diff
if: steps.update_dropdown.outputs.modified == 'true'
run: git diff --color
- name: Create/Update Pull Request
id: create-pr
if: |
steps.update_dropdown.outputs.modified == 'true' &&
github.event_name != 'pull_request'
uses: peter-evans/create-pull-request@v8
with:
add-paths: |
.github/ISSUE_TEMPLATE/*.yml
token: ${{ secrets.GH_BOT_TOKEN }}
commit-message: "chore: Update repositories list in roadmap.yml"
branch: bot/update-repositories-list
delete-branch: true
title: "chore: Update repositories list in roadmap.yml"
body: |
This PR updates the list of repositories in the roadmap issue template.
The list was automatically generated by a GitHub Action.
labels: |
auto-approve
auto-merge
- name: Automerge PR
env:
GH_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
if: |
steps.create-pr.outputs.pull-request-number != '' &&
steps.update_dropdown.outputs.modified == 'true' &&
github.event_name != 'pull_request'
run: |
gh pr merge \
--auto \
--delete-branch \
--squash \
"${{ steps.create-pr.outputs.pull-request-number }}"