Skip to content

Commit

Permalink
Merge pull request #34 from joshjohanning/main
Browse files Browse the repository at this point in the history
Add markdown results as output and fix actionsToken
  • Loading branch information
samsmithnz authored May 16, 2024
2 parents 90a1679 + 7de051e commit 9a267b9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ A GitHub Action to roughly calculate DORA lead time for changes This is not mean
- `app-private-key` optional, string, defaults to '', private key which has been generated for the installed instance of the GitHub app. Must be provided without leading `'-----BEGIN RSA PRIVATE KEY----- '` and trailing `' -----END RSA PRIVATE KEY-----'`.

To test the current repo (same as where the action runs)
```
```yml
- uses: DeveloperMetrics/lead-time-for-changes@main
with:
workflows: 'CI'
```
To test another repo, with all arguments
```
```yml
- name: Test another repo
uses: DeveloperMetrics/lead-time-for-changes@main
with:
Expand All @@ -47,7 +47,7 @@ To test another repo, with all arguments
```
To use a PAT token to access another (potentially private) repo:
```
```yml
- name: Test elite repo with PAT Token
uses: DeveloperMetrics/lead-time-for-changes@main
with:
Expand All @@ -57,7 +57,7 @@ To use a PAT token to access another (potentially private) repo:
```
Use the built in Actions GitHub Token to retrieve the metrics
```
```yml
- name: Test this repo with GitHub Token
uses: DeveloperMetrics/lead-time-for-changes@main
with:
Expand All @@ -66,7 +66,7 @@ Use the built in Actions GitHub Token to retrieve the metrics
```
Gather the metric from another repository using GitHub App authentication method:
```
```yml
- name: Test another repo with GitHub App
uses: DeveloperMetrics/lead-time-for-changes@main
with:
Expand All @@ -77,6 +77,17 @@ Gather the metric from another repository using GitHub App authentication method
app-private-key: "${{ secrets.APPPRIVATEKEY }}"
```
Use the markdown file output for some other action downstream:
```yml
- name: Generate lead time for changes markdown file
uses: DeveloperMetrics/lead-time-for-changes@main
id: lead-time
with:
workflows: 'CI'
actions-token: "${{ secrets.GITHUB_TOKEN }}"
- run: cat ${{ steps.lead-time.outputs.markdown-file }})
```
# Setup
Permissions: Read access to actions, metadata, and pull requests
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ inputs:
app-private-key:
description: 'private key which has been generated for the installed instance of the GitHub app'
default: ""
outputs:
markdown-file:
description: "The markdown that will be posted to the job summary, so that the markdown can saved and used other places (e.g.: README.md)"
value: ${{ steps.lead-time.outputs.markdown-file }}
runs:
using: "composite"
steps:
- name: Run DORA lead time for changes
id: lead-time
shell: pwsh
run: |
$result = ${{ github.action_path }}/src/leadtimeforchanges.ps1 -ownerRepo "${{ inputs.owner-repo }}" -workflows "${{ inputs.workflows }}" -branch "${{ inputs.default-branch }}" -numberOfDays ${{ inputs.number-of-days }} -commitCountingMethod ${{ inputs.commit-counting-method }} -patToken "${{ inputs.pat-token }}" -actionsToken "${{ inputs.actions-token }}" -appId "${{ inputs.app-id }}" -appInstallationId "${{ inputs.app-install-id }}" -appPrivateKey "${{ inputs.app-private-key }}"
$filePath="dora-lead-time-markdown.md"
Set-Content -Path $filePath -Value $result
"markdown-file=$filePath" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
Write-Output $result >> $env:GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion src/leadtimeforchanges.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function GetAuthHeader ([string] $patToken, [string] $actionsToken, [string] $ap
elseif (![string]::IsNullOrEmpty($actionsToken))
{
Write-Host "Authentication detected: GITHUB TOKEN"
$authHeader = @{Authorization=("Bearer {0}" -f $base64AuthInfo)}
$authHeader = @{Authorization=("Bearer {0}" -f $actionsToken)}
}
elseif (![string]::IsNullOrEmpty($appId)) # GitHup App auth
{
Expand Down

0 comments on commit 9a267b9

Please sign in to comment.