-
Notifications
You must be signed in to change notification settings - Fork 340
Sync eng/common directory with azure-sdk-tools for PR 14219 #3833
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
5 commits
Select commit
Hold shift + click to select a range
8a6ca0e
Add action to use github app via github workflows
weshaggard c6c3089
Add note about environment
weshaggard 52065f1
Use env variables to help prevent injection attacks
weshaggard b5fd9fc
Remove note about outputs
weshaggard 8cdeb1f
Add test workflow for login-to-github
weshaggard 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
There are no files selected for viewing
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,102 @@ | ||
| # Login to GitHub - Composite Action | ||
| # | ||
| # Mints a GitHub App installation access token using Azure Key Vault signing. | ||
| # This action wraps eng/common/scripts/login-to-github.ps1 for use in GitHub | ||
| # Actions workflows. The same script is used by Azure DevOps pipelines via | ||
| # eng/common/pipelines/templates/steps/login-to-github.yml. | ||
| # | ||
| # IMPORTANT: This action requires Azure CLI to be pre-authenticated. | ||
| # You must call azure/login BEFORE this action in your workflow. | ||
| # This is because composite actions cannot call azure/login internally. | ||
| # | ||
| # Usage (single owner): | ||
| # jobs: | ||
| # my-job: | ||
| # # An environment is required for OIDC (federated credential) login. | ||
| # # Work with EngSys to configure the environment with the federated | ||
| # # credential for the AzureSDKEngKeyVault Secrets service connection. | ||
| # environment: AzureSDKEngKeyVault | ||
| # permissions: | ||
| # id-token: write # Required for azure/login OIDC | ||
| # steps: | ||
| # # Step 1: Authenticate to Azure (required before this action) | ||
| # - uses: azure/login@v2 | ||
| # with: | ||
| # client-id: 5786d1fb-187e-4ca9-9a81-ab89ea278986 | ||
| # tenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 | ||
| # subscription-id: a18897a6-7e44-457d-9260-f2854c0aca42 | ||
| # | ||
| # # Step 2: Mint GitHub App token | ||
| # - uses: ./eng/common/actions/login-to-github | ||
| # with: | ||
| # token-owners: Azure | ||
| # | ||
| # # Step 3: Use the token (available as env var in all subsequent steps) | ||
| # - run: gh pr list --repo Azure/azure-sdk-tools | ||
| # env: | ||
| # GH_TOKEN: ${{ env.GH_TOKEN }} | ||
| # | ||
| # Usage (multiple owners): | ||
| # - uses: ./eng/common/actions/login-to-github | ||
| # with: | ||
| # token-owners: Azure,azure-sdk,MicrosoftDocs | ||
| # | ||
| # - run: gh pr list --repo Azure/azure-sdk-tools | ||
| # env: | ||
| # GH_TOKEN: ${{ env.GH_TOKEN_Azure }} | ||
| # | ||
| # Tokens are exported to GITHUB_ENV so all subsequent steps can reference | ||
| # them as ${{ env.GH_TOKEN }} (single owner) or ${{ env.GH_TOKEN_<Owner> }} | ||
| # (multiple owners). This matches the Azure DevOps behavior where tokens | ||
| # are set as pipeline variables. | ||
|
|
||
| name: 'Login to GitHub' | ||
| description: 'Mint a GitHub App installation token via Azure Key Vault signing' | ||
|
|
||
| inputs: | ||
| token-owners: | ||
| description: > | ||
| Comma-separated list of GitHub organizations or users for which to | ||
| obtain installation tokens (e.g. "Azure" or "Azure,azure-sdk"). | ||
| required: false | ||
| default: 'Azure' | ||
| variable-name-prefix: | ||
| description: > | ||
| Prefix for the exported variable name. With a single owner the | ||
| variable is named exactly this (default GH_TOKEN). With multiple | ||
| owners each variable is named <prefix>_<owner>. | ||
| required: false | ||
| default: 'GH_TOKEN' | ||
| key-vault-name: | ||
| description: 'Azure Key Vault name containing the signing key' | ||
| required: false | ||
| default: 'azuresdkengkeyvault' | ||
| key-name: | ||
| description: 'Name of the RSA key in Key Vault' | ||
| required: false | ||
| default: 'azure-sdk-automation' | ||
| app-id: | ||
| description: 'GitHub App numeric ID' | ||
| required: false | ||
| default: '1086291' | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - shell: pwsh | ||
| env: | ||
| INPUT_TOKEN_OWNERS: ${{ inputs.token-owners }} | ||
| INPUT_VARIABLE_NAME_PREFIX: ${{ inputs.variable-name-prefix }} | ||
| INPUT_KEY_VAULT_NAME: ${{ inputs.key-vault-name }} | ||
| INPUT_KEY_NAME: ${{ inputs.key-name }} | ||
| INPUT_APP_ID: ${{ inputs.app-id }} | ||
| ACTION_PATH: ${{ github.action_path }} | ||
| run: | | ||
| $scriptPath = Join-Path $env:ACTION_PATH ".." ".." "scripts" "login-to-github.ps1" | ||
| $owners = $env:INPUT_TOKEN_OWNERS -split ',' | ForEach-Object { $_.Trim() } | ||
| & $scriptPath ` | ||
| -KeyVaultName $env:INPUT_KEY_VAULT_NAME ` | ||
| -KeyName $env:INPUT_KEY_NAME ` | ||
| -GitHubAppId $env:INPUT_APP_ID ` | ||
| -InstallationTokenOwners $owners ` | ||
| -VariableNamePrefix $env:INPUT_VARIABLE_NAME_PREFIX |
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
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.