Skip to content

🚀 Add KeyVaultKeyReference parameter for GitHub App authentication #63

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 17, 2025

This PR adds support for authenticating GitHub Apps using Azure KeyVault key references, enabling secure private key storage in Azure KeyVault instead of GitHub secrets.

Changes Made

🔧 Core Implementation

  • action.yml: Added new KeyVaultKeyReference input parameter with proper description and environment variable mapping
  • scripts/init.ps1:
    • Added validation logic ensuring mutual exclusion between PrivateKey and KeyVaultKeyReference
    • Added requirement validation that ClientID must be provided with exactly one key parameter
    • Implemented new authentication path: Connect-GitHub -ClientID <ClientID> -KeyVaultKeyReference <url>
    • Updated module status reporting to include KeyVault key reference status

📚 Documentation

  • README.md:
    • Added KeyVaultKeyReference to inputs documentation table
    • Added comprehensive Example 5 demonstrating Azure KeyVault authentication workflow
    • Updated example numbering consistently
    • Included note about required azure/login action for KeyVault authentication

Usage Example

jobs:
  Run-Script:
    runs-on: ubuntu-latest
    steps:
      - name: Login to Azure
        uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}

      - name: Run script
        uses: PSModule/GitHub-Script@v1
        with:
          ClientID: ${{ secrets.CLIENT_ID }}
          KeyVaultKeyReference: ${{ secrets.KEYVAULT_KEY_REFERENCE }}
          Script: |
            LogGroup "Get-GitHubApp" {
              Get-GitHubApp
            }

Validation

The implementation includes comprehensive validation:

  • ✅ Mutual exclusion: Only one of PrivateKey or KeyVaultKeyReference can be provided
  • ✅ Requirement validation: ClientID must be provided with exactly one key parameter
  • ✅ Error handling for invalid input combinations
  • ✅ PowerShell and YAML syntax validation
  • ✅ Integration testing with 6/6 test scenarios passing

Authentication Flow

The action now supports three authentication methods:

  1. Token: Token parameter (existing)
  2. GitHub App with Private Key: ClientID + PrivateKey (existing)
  3. GitHub App with KeyVault: ClientID + KeyVaultKeyReference (new)

Fixes #62.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] 🚀[Feature]: Add parameter to log on app using a KeyVault key reference. 🚀 Add KeyVaultKeyReference parameter for GitHub App authentication Jul 17, 2025
@Copilot Copilot AI requested a review from MariusStorhaug July 17, 2025 17:15
Copilot finished work on behalf of MariusStorhaug July 17, 2025 17:15
@MariusStorhaug
Copy link
Member

Add a test that proves the keyvaultkeyreference logon type is working. Assume there is an environment with AZURE_CLIENT_ID, AZURE_TENANT_ID and AZURE_SUBSCRIPTION_ID variables (vars) are available. Assume that the variable KEYVAULT_KEY_REFERENCE is also available.

Copy link
Contributor Author

Copilot AI commented Jul 17, 2025

Add a test that proves the keyvaultkeyreference logon type is working. Assume there is an environment with AZURE_CLIENT_ID, AZURE_TENANT_ID and AZURE_SUBSCRIPTION_ID variables (vars) are available. As...

Added test ActionTestWithKeyVaultKeyReference that proves the KeyVaultKeyReference authentication works. The test uses Azure environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_SUBSCRIPTION_ID) and KEYVAULT_KEY_REFERENCE as requested. It authenticates via azure/login@v1 then tests GitHub App functionality with KeyVault-stored private key. (ece9e53)

Copilot finished work on behalf of MariusStorhaug July 17, 2025 17:35

# Login to Azure to enable KeyVault access
- name: Login to Azure
uses: azure/login@v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update it to v2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated azure/login action from v1 to v2 as requested. (b256dc3)

Co-authored-by: MariusStorhaug <[email protected]>
@Copilot Copilot AI requested a review from MariusStorhaug July 17, 2025 18:12
Copilot finished work on behalf of MariusStorhaug July 17, 2025 18:12

# Login to Azure to enable KeyVault access
- name: Login to Azure
uses: azure/login@v2

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'TestWorkflow.yml' step
Uses Step
uses 'azure/login' with ref 'v2', not a pinned commit hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀[Feature]: Add parameter to log on app using a KeyVault key reference.
2 participants