-
Notifications
You must be signed in to change notification settings - Fork 1
feat(workflows): teams reuse bootstrap and deploy workflows for independence #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
35bcbce
fix(workflows): teams reuse workflows to bootstrap and deploy
amaralc 4d673c3
docs(insights): add workflow confirmation pattern
amaralc 309ce53
config: potential fix for code scanning alert no. 69: Workflow does n…
amaralc 9f03b4e
fix(github-actions): scope permissions to job level for least privilege
amaralc 8862040
fix(workflows): force job dependencies
amaralc a917964
fix(ci): add job dependencies
amaralc b3c295f
fix(ci): move workflows to .github folder
amaralc 599aba4
fix(ci): pass secrets via environment variables for proper masking
amaralc de5b50e
docs: add insight on secret masking in GitHub Actions workflows
amaralc c584fc1
fix(ci): avoid expanding secrets in actions
amaralc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
.github/workflows/teams-kernel-workflows-bootstrap-team.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| name: Bootstrap Team Infrastructure (Reusable) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| team-name: | ||
| required: true | ||
| type: string | ||
| description: 'Team name (kernel, people, things)' | ||
| secrets: | ||
| GCP_WORKLOAD_IDENTITY_PROVIDER: | ||
| required: true | ||
| GCP_SERVICE_ACCOUNT_EMAIL: | ||
| required: true | ||
| OWNER_ACCOUNT_EMAIL: | ||
| required: true | ||
| GCP_ORGANIZATION_ID: | ||
| required: true | ||
| GCP_BILLING_ACCOUNT_ID: | ||
| required: true | ||
| DOMAIN_NAME: | ||
| required: true | ||
| GITHUB_USERNAME: | ||
| required: true | ||
| NEON_API_KEY: | ||
| required: true | ||
| NEON_PROJECT_LOCATION: | ||
| required: true | ||
| MONGODB_ATLAS_ORG_ID: | ||
| required: true | ||
| MONGODB_ATLAS_PUBLIC_KEY: | ||
| required: true | ||
| MONGODB_ATLAS_PRIVATE_KEY: | ||
| required: true | ||
| NX_CLOUD_ACCESS_TOKEN_READ_WRITE: | ||
| required: true | ||
| NX_CLOUD_ACCESS_TOKEN_READ: | ||
| required: true | ||
|
|
||
| jobs: | ||
| bootstrap: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
|
|
||
| - name: Authenticate to Google Cloud | ||
| id: auth | ||
| uses: google-github-actions/auth@c200f3691d83b41bf9bbd8638997a462592937ed # v2.1.13 | ||
| with: | ||
| workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }} | ||
|
|
||
| - name: Set up Cloud SDK | ||
| uses: google-github-actions/setup-gcloud@e427ad8a34f8676edf47cf7d7925499adf3eb74f # v2.2.1 | ||
|
|
||
| - name: Install gh CLI | ||
| run: | | ||
| type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) | ||
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
| && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | ||
| && sudo apt update \ | ||
| && sudo apt install gh -y | ||
|
|
||
| - name: Run bootstrap script for ${{ inputs.team-name }} | ||
| env: | ||
| OWNER_ACCOUNT_EMAIL: ${{ secrets.OWNER_ACCOUNT_EMAIL }} | ||
| GCP_ORGANIZATION_ID: ${{ secrets.GCP_ORGANIZATION_ID }} | ||
| GCP_BILLING_ACCOUNT_ID: ${{ secrets.GCP_BILLING_ACCOUNT_ID }} | ||
| DOMAIN_NAME: ${{ secrets.DOMAIN_NAME }} | ||
| GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }} | ||
| NEON_API_KEY: ${{ secrets.NEON_API_KEY }} | ||
| NEON_PROJECT_LOCATION: ${{ secrets.NEON_PROJECT_LOCATION }} | ||
| MONGODB_ATLAS_ORG_ID: ${{ secrets.MONGODB_ATLAS_ORG_ID }} | ||
| MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY }} | ||
| MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY }} | ||
| NX_CLOUD_ACCESS_TOKEN_READ_WRITE: ${{ secrets.NX_CLOUD_ACCESS_TOKEN_READ_WRITE }} | ||
| NX_CLOUD_ACCESS_TOKEN_READ: ${{ secrets.NX_CLOUD_ACCESS_TOKEN_READ }} | ||
| run: | | ||
| echo "Bootstrap: Starting ${{ inputs.team-name }} team infrastructure bootstrap" | ||
| sh teams/kernel/iac/bootstrap/project-setup.sh \ | ||
| --owner-account-email="$OWNER_ACCOUNT_EMAIL" \ | ||
| --gcp-organization-id="$GCP_ORGANIZATION_ID" \ | ||
| --gcp-billing-account-id="$GCP_BILLING_ACCOUNT_ID" \ | ||
| --domain-name="$DOMAIN_NAME" \ | ||
| --github-username="$GITHUB_USERNAME" \ | ||
| --github-repository="${{ github.repository }}" \ | ||
| --neon-api-key="$NEON_API_KEY" \ | ||
| --neon-project-location="$NEON_PROJECT_LOCATION" \ | ||
| --mongodb-atlas-org-id="$MONGODB_ATLAS_ORG_ID" \ | ||
| --mongodb-atlas-public-key="$MONGODB_ATLAS_PUBLIC_KEY" \ | ||
| --mongodb-atlas-private-key="$MONGODB_ATLAS_PRIVATE_KEY" \ | ||
| --nx-cloud-access-token-read-write="$NX_CLOUD_ACCESS_TOKEN_READ_WRITE" \ | ||
| --nx-cloud-access-token-read="$NX_CLOUD_ACCESS_TOKEN_READ" | ||
| echo "Bootstrap: Completed ${{ inputs.team-name }} team infrastructure bootstrap" | ||
|
|
||
| - name: Verify bootstrap success | ||
| run: | | ||
| echo "Bootstrap: Verifying ${{ inputs.team-name }} infrastructure" | ||
| gcloud projects list --filter="name:*${{ inputs.team-name }}*" --format="table(name,projectId)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| name: Bootstrap All Team Infrastructure | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| teams: | ||
| description: 'Teams to bootstrap (all, kernel, people, things, or space-separated list)' | ||
| required: false | ||
| default: 'all' | ||
|
|
||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| jobs: | ||
| bootstrap-kernel: | ||
| name: Bootstrap Kernel Team | ||
| uses: ./.github/workflows/teams-kernel-workflows-bootstrap-team.yml | ||
| permissions: | ||
| contents: read | ||
| if: | | ||
| github.event.inputs.teams == 'all' || | ||
| github.event.inputs.teams == 'kernel' || | ||
| contains(github.event.inputs.teams, 'kernel') | ||
| secrets: | ||
| GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
| GCP_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }} | ||
| OWNER_ACCOUNT_EMAIL: ${{ secrets.OWNER_ACCOUNT_EMAIL }} | ||
| GCP_ORGANIZATION_ID: ${{ secrets.GCP_ORGANIZATION_ID }} | ||
| GCP_BILLING_ACCOUNT_ID: ${{ secrets.GCP_BILLING_ACCOUNT_ID }} | ||
| DOMAIN_NAME: ${{ secrets.DOMAIN_NAME }} | ||
| GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }} | ||
| NEON_API_KEY: ${{ secrets.NEON_API_KEY }} | ||
| NEON_PROJECT_LOCATION: ${{ secrets.NEON_PROJECT_LOCATION }} | ||
| MONGODB_ATLAS_ORG_ID: ${{ secrets.MONGODB_ATLAS_ORG_ID }} | ||
| MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY }} | ||
| MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY }} | ||
| NX_CLOUD_ACCESS_TOKEN_READ_WRITE: ${{ secrets.NX_CLOUD_ACCESS_TOKEN_READ_WRITE }} | ||
| NX_CLOUD_ACCESS_TOKEN_READ: ${{ secrets.NX_CLOUD_ACCESS_TOKEN_READ }} | ||
| with: | ||
| team-name: kernel | ||
|
|
||
| bootstrap-people: | ||
| name: Bootstrap People Team | ||
| uses: ./.github/workflows/teams-kernel-workflows-bootstrap-team.yml | ||
| needs: bootstrap-kernel | ||
| permissions: | ||
| contents: read | ||
| if: | | ||
| needs.bootstrap-kernel.result == 'success' && ( | ||
| github.event.inputs.teams == 'all' || | ||
| github.event.inputs.teams == 'people' || | ||
| contains(github.event.inputs.teams, 'people') | ||
| ) | ||
| secrets: | ||
| GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
| GCP_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }} | ||
| OWNER_ACCOUNT_EMAIL: ${{ secrets.OWNER_ACCOUNT_EMAIL }} | ||
| GCP_ORGANIZATION_ID: ${{ secrets.GCP_ORGANIZATION_ID }} | ||
| GCP_BILLING_ACCOUNT_ID: ${{ secrets.GCP_BILLING_ACCOUNT_ID }} | ||
| DOMAIN_NAME: ${{ secrets.DOMAIN_NAME }} | ||
| GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }} | ||
| NEON_API_KEY: ${{ secrets.NEON_API_KEY }} | ||
| NEON_PROJECT_LOCATION: ${{ secrets.NEON_PROJECT_LOCATION }} | ||
| MONGODB_ATLAS_ORG_ID: ${{ secrets.MONGODB_ATLAS_ORG_ID }} | ||
| MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY }} | ||
| MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY }} | ||
| NX_CLOUD_ACCESS_TOKEN_READ_WRITE: ${{ secrets.NX_CLOUD_ACCESS_TOKEN_READ_WRITE }} | ||
| NX_CLOUD_ACCESS_TOKEN_READ: ${{ secrets.NX_CLOUD_ACCESS_TOKEN_READ }} | ||
| with: | ||
| team-name: people | ||
|
|
||
| bootstrap-things: | ||
| name: Bootstrap Things Team | ||
| uses: ./.github/workflows/teams-kernel-workflows-bootstrap-team.yml | ||
| needs: bootstrap-kernel | ||
| permissions: | ||
| contents: read | ||
| if: | | ||
| needs.bootstrap-kernel.result == 'success' && ( | ||
| github.event.inputs.teams == 'all' || | ||
| github.event.inputs.teams == 'things' || | ||
| contains(github.event.inputs.teams, 'things') | ||
| ) | ||
| secrets: | ||
| GCP_WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
| GCP_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }} | ||
| OWNER_ACCOUNT_EMAIL: ${{ secrets.OWNER_ACCOUNT_EMAIL }} | ||
| GCP_ORGANIZATION_ID: ${{ secrets.GCP_ORGANIZATION_ID }} | ||
| GCP_BILLING_ACCOUNT_ID: ${{ secrets.GCP_BILLING_ACCOUNT_ID }} | ||
| DOMAIN_NAME: ${{ secrets.DOMAIN_NAME }} | ||
| GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }} | ||
| NEON_API_KEY: ${{ secrets.NEON_API_KEY }} | ||
| NEON_PROJECT_LOCATION: ${{ secrets.NEON_PROJECT_LOCATION }} | ||
| MONGODB_ATLAS_ORG_ID: ${{ secrets.MONGODB_ATLAS_ORG_ID }} | ||
| MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY }} | ||
| MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY }} | ||
| NX_CLOUD_ACCESS_TOKEN_READ_WRITE: ${{ secrets.NX_CLOUD_ACCESS_TOKEN_READ_WRITE }} | ||
| NX_CLOUD_ACCESS_TOKEN_READ: ${{ secrets.NX_CLOUD_ACCESS_TOKEN_READ }} | ||
| with: | ||
| team-name: things | ||
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.