Skip to content

Commit

Permalink
upgrade (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Sep 13, 2022
1 parent e93917d commit c2a6510
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- weekly schedule to the synchronization workflow
- fix workflow which executes user defined config transforms on PRs and after Apply
- shared config fix rule which adds missing default branch protections
- shared action for adding a file to all repositories

### Changed
- Synchronization script: to use GitHub API directly instead of relying on TF GH Provider's Data Sources
Expand Down
27 changes: 27 additions & 0 deletions scripts/src/actions/shared/add-file-to-all-repos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {Config} from '../../yaml/config'
import {Repository} from '../../resources/repository'
import {RepositoryFile} from '../../resources/repository-file'

export async function addFileToAllRepos(
name: string,
content: string,
exclude: string[] = []
): Promise<void> {
const config = Config.FromPath()

const repositories = config
.getResources(Repository)
.filter(r => !r.archived)
.filter(r => !exclude.includes(r.name))

for (const repository of repositories) {
const file = new RepositoryFile(repository.name, name)
file.content = content
if (!config.someResource(file)) {
console.log(`Adding ${file.file} file to ${file.repository} repository`)
config.addResource(file)
}
}

config.save()
}
2 changes: 1 addition & 1 deletion scripts/src/actions/shared/protect-default-branches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function protectDefaultBranches(
): Promise<void> {
const config = Config.FromPath()

const repositories = config.getResources(Repository)
const repositories = config.getResources(Repository).filter(r => !r.archived)

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

0 comments on commit c2a6510

Please sign in to comment.