Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.2.9
terraform_wrapper: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.2.9
terraform_wrapper: false
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
git fetch origin "pull/${NUMBER}/head"
rm -rf github && git checkout "${SHA}" -- github
- name: Setup terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.2.9
terraform_wrapper: false
Expand All @@ -117,7 +117,7 @@ jobs:
# NOTE(galargh, 2024-02-15): This will only work if GitHub as Code is used for a single organization
- name: Comment on pull request
if: github.event_name == 'pull_request_target' && steps.fix.outputs.comment
uses: marocchino/sticky-pull-request-comment@fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 # v2.3.1
uses: marocchino/sticky-pull-request-comment@67d0dec7b07ed060a405f9b2a64b8ab319fdd7db # v2.9.2
with:
header: fix
number: ${{ github.event.pull_request.number }}
Expand All @@ -135,10 +135,11 @@ jobs:
steps:
- name: Generate app token
id: token
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.RW_GITHUB_APP_ID }}
installation_id: ${{ secrets[format('RW_GITHUB_APP_INSTALLATION_ID_{0}', github.repository_owner)] || secrets.RW_GITHUB_APP_INSTALLATION_ID }}
installation_retrieval_mode: id
installation_retrieval_payload: ${{ secrets[format('RW_GITHUB_APP_INSTALLATION_ID_{0}', github.repository_owner)] || secrets.RW_GITHUB_APP_INSTALLATION_ID }}
private_key: ${{ secrets.RW_GITHUB_APP_PEM_FILE }}
- name: Checkout
uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
git fetch origin "pull/${NUMBER}/head"
rm -rf github && git checkout "${SHA}" -- github
- name: Setup terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.2.9
terraform_wrapper: false
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
git fetch origin "pull/${NUMBER}/head"
rm -rf github && git checkout "${SHA}" -- github
- name: Setup terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.2.9
terraform_wrapper: false
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
echo 'EOF' >> $GITHUB_ENV
working-directory: terraform
- name: Comment on pull request
uses: marocchino/sticky-pull-request-comment@fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 # v2.3.1
uses: marocchino/sticky-pull-request-comment@67d0dec7b07ed060a405f9b2a64b8ab319fdd7db # v2.9.2
with:
header: plan
number: ${{ github.event.pull_request.number }}
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.2.9
terraform_wrapper: false
Expand Down Expand Up @@ -107,10 +107,11 @@ jobs:
steps:
- name: Generate app token
id: token
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.RW_GITHUB_APP_ID }}
installation_id: ${{ secrets[format('RW_GITHUB_APP_INSTALLATION_ID_{0}', github.repository_owner)] || secrets.RW_GITHUB_APP_INSTALLATION_ID }}
installation_retrieval_mode: id
installation_retrieval_payload: ${{ secrets[format('RW_GITHUB_APP_INSTALLATION_ID_{0}', github.repository_owner)] || secrets.RW_GITHUB_APP_INSTALLATION_ID }}
private_key: ${{ secrets.RW_GITHUB_APP_PEM_FILE }}
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Added
- shared action for adding a collaborator to all repositories
- clean workflow which removes resources from state
- information on how to handle private GitHub Management repository
- warning about GitHub Management repository access
Expand All @@ -22,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- new args for repositories and branch protection rules

### Changed
- **BREAKING**: turned scripts into an ESM project (please ensure you remove the following files during the upgrade: `scripts/.eslintignore`, `scripts/.eslintrc.json`, `scripts/jest.config.js`, `jest.d.ts`, `jest.setup.ts`; please update your imports in the `scripts/src/actions/fix-yaml-config.ts` file to include the `.js` extension)
- **BREAKING**: Updated the signatures of all the shared actions; now the runAction function will persist the changes to disk while action functions will operate on the in-memory state (please update your imports in the `scripts/src/actions/fix-yaml-config.ts` file accordingly)
- Synchronization script: to use GitHub API directly instead of relying on TF GH Provider's Data Sources
- Configuration: replaced multiple JSONs with a single, unified YAML
- Synchronization script: rewrote the script in JS
Expand All @@ -46,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- updated upload and download artifacts actions to v4

### Fixed
- fixed how terraform state is accessed before it the initial synchronization
- links to supported resources in HOWTOs
- posting PR comments when terraform plan output is very long
- PR parsing in the update workflow
Expand Down
4 changes: 2 additions & 2 deletions docs/HOWTOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ I want to ensure that all the public repositories in my organization have their
To do that, I ensure the following content is present in `scripts/src/actions/fix-yaml-config.ts`:
```ts
import 'reflect-metadata'
import { protectDefaultBranches } from './shared/protect-default-branches'
import { runProtectDefaultBranches } from './shared/protect-default-branches'

protectDefaultBranches()
runProtectDefaultBranches()
```
2 changes: 2 additions & 0 deletions docs/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
- [ ] Rename the `$GITHUB_ORGANIZATION_NAME.yml` in `github` to the name of the GitHub organization
- [ ] Push the changes to `$GITHUB_MGMT_REPOSITORY_DEFAULT_BRANCH`

> [!WARNING] Please note that until you [synchronize GitHub Management with GitHub](#github-management-sync-flow) for the first time, the workflows that depend on Terraform state, like `Fix`, `Plan` or `Apply`, will fail. This is because the state is not yet initialized.

## GitHub Management Sync Flow

- [ ] Follow [How to synchronize GitHub Management with GitHub?](HOWTOS.md#synchronize-github-management-with-github) to commit the terraform lock and initialize terraform state
Expand Down
51 changes: 51 additions & 0 deletions github/.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"additionalProperties": {
"additionalProperties": false,
"properties": {
"advanced_security": {
"type": "boolean"
},
"allow_auto_merge": {
"type": "boolean"
},
Expand All @@ -39,6 +42,9 @@
"allow_squash_merge": {
"type": "boolean"
},
"allow_update_branch": {
"type": "boolean"
},
"archive_on_destroy": {
"type": "boolean"
},
Expand Down Expand Up @@ -108,6 +114,9 @@
"gitignore_template": {
"type": "string"
},
"has_discussions": {
"type": "boolean"
},
"has_downloads": {
"type": "boolean"
},
Expand All @@ -129,9 +138,21 @@
"is_template": {
"type": "boolean"
},
"labels": {
"additionalProperties": {
"$ref": "#/definitions/RepositoryLabel"
},
"type": "object"
},
"license_template": {
"type": "string"
},
"merge_commit_message": {
"type": "string"
},
"merge_commit_title": {
"type": "string"
},
"pages": {
"additionalProperties": false,
"properties": {
Expand All @@ -153,6 +174,18 @@
},
"type": "object"
},
"secret_scanning": {
"type": "boolean"
},
"secret_scanning_push_protection": {
"type": "boolean"
},
"squash_merge_commit_message": {
"type": "string"
},
"squash_merge_commit_title": {
"type": "string"
},
"teams": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -276,9 +309,15 @@
"allows_force_pushes": {
"type": "boolean"
},
"blocks_creations": {
"type": "boolean"
},
"enforce_admins": {
"type": "boolean"
},
"lock_branch": {
"type": "boolean"
},
"push_restrictions": {
"items": {
"type": "string"
Expand Down Expand Up @@ -354,6 +393,18 @@
},
"type": "object"
},
"RepositoryLabel": {
"additionalProperties": false,
"properties": {
"color": {
"type": "string"
},
"description": {
"type": "string"
}
},
"type": "object"
},
"Visibility": {
"enum": [
"private",
Expand Down
3 changes: 0 additions & 3 deletions scripts/.eslintignore

This file was deleted.

56 changes: 0 additions & 56 deletions scripts/.eslintrc.json

This file was deleted.

22 changes: 1 addition & 21 deletions scripts/__tests__/__resources__/github/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,7 @@ repositories:
visibility: public
vulnerability_alerts: false
rust-sccache-action:
advanced_security: false
allow_auto_merge: false
allow_merge_commit: true
allow_rebase_merge: true
allow_squash_merge: true
archived: false
auto_init: false
default_branch: main
delete_branch_on_merge: false
has_downloads: true
has_issues: true
has_projects: true
has_wiki: true
is_template: false
secret_scanning_push_protection: false
secret_scanning: false
teams:
maintain:
- ipdx
visibility: public
vulnerability_alerts: true
archived: true
tf-aws-gh-runner:
advanced_security: false
allow_auto_merge: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ locals {
"github_repository_file",
"github_issue_label"
]
ignore = {
"repositories" = ["ignored"]
"teams" = ["ignored"]
"users" = ["ignored"]
}
}
4 changes: 2 additions & 2 deletions scripts/__tests__/__resources__/terraform/terraform.tfstate
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_squash_merge": true,
"archived": false,
"archived": true,
"branches": [
{
"name": "arm64",
Expand Down Expand Up @@ -1644,7 +1644,7 @@
"allow_rebase_merge": true,
"allow_squash_merge": true,
"archive_on_destroy": null,
"archived": false,
"archived": true,
"auto_init": false,
"branches": [
{
Expand Down
Loading