Skip to content

Commit 426ce09

Browse files
authored
Merge pull request #49 from libp2p/master-upgrade
upgrade (#12)
2 parents e93917d + c2a6510 commit 426ce09

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- weekly schedule to the synchronization workflow
1717
- fix workflow which executes user defined config transforms on PRs and after Apply
1818
- shared config fix rule which adds missing default branch protections
19+
- shared action for adding a file to all repositories
1920

2021
### Changed
2122
- Synchronization script: to use GitHub API directly instead of relying on TF GH Provider's Data Sources
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {Config} from '../../yaml/config'
2+
import {Repository} from '../../resources/repository'
3+
import {RepositoryFile} from '../../resources/repository-file'
4+
5+
export async function addFileToAllRepos(
6+
name: string,
7+
content: string,
8+
exclude: string[] = []
9+
): Promise<void> {
10+
const config = Config.FromPath()
11+
12+
const repositories = config
13+
.getResources(Repository)
14+
.filter(r => !r.archived)
15+
.filter(r => !exclude.includes(r.name))
16+
17+
for (const repository of repositories) {
18+
const file = new RepositoryFile(repository.name, name)
19+
file.content = content
20+
if (!config.someResource(file)) {
21+
console.log(`Adding ${file.file} file to ${file.repository} repository`)
22+
config.addResource(file)
23+
}
24+
}
25+
26+
config.save()
27+
}

scripts/src/actions/shared/protect-default-branches.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export async function protectDefaultBranches(
77
): Promise<void> {
88
const config = Config.FromPath()
99

10-
const repositories = config.getResources(Repository)
10+
const repositories = config.getResources(Repository).filter(r => !r.archived)
1111

1212
for (const repository of repositories) {
1313
if (includePrivate || repository.visibility !== Visibility.Private) {

0 commit comments

Comments
 (0)