File tree 3 files changed +29
-1
lines changed
scripts/src/actions/shared
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
16
- weekly schedule to the synchronization workflow
17
17
- fix workflow which executes user defined config transforms on PRs and after Apply
18
18
- shared config fix rule which adds missing default branch protections
19
+ - shared action for adding a file to all repositories
19
20
20
21
### Changed
21
22
- Synchronization script: to use GitHub API directly instead of relying on TF GH Provider's Data Sources
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export async function protectDefaultBranches(
7
7
) : Promise < void > {
8
8
const config = Config . FromPath ( )
9
9
10
- const repositories = config . getResources ( Repository )
10
+ const repositories = config . getResources ( Repository ) . filter ( r => ! r . archived )
11
11
12
12
for ( const repository of repositories ) {
13
13
if ( includePrivate || repository . visibility !== Visibility . Private ) {
You can’t perform that action at this time.
0 commit comments