From 11d7931f81997efaa0d472be1d0b1fe9b489384e Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Mon, 25 Mar 2024 15:03:47 -0500 Subject: [PATCH 1/3] feat: adding markdown result as an output --- action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/action.yml b/action.yml index 413093a..3a3ea73 100644 --- a/action.yml +++ b/action.yml @@ -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 From ab4b08ce68aacc8326921876e7f365596ae26af7 Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Tue, 26 Mar 2024 09:46:19 -0500 Subject: [PATCH 2/3] fix: actionsToken --- src/leadtimeforchanges.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/leadtimeforchanges.ps1 b/src/leadtimeforchanges.ps1 index 8e89bce..a7c25c0 100644 --- a/src/leadtimeforchanges.ps1 +++ b/src/leadtimeforchanges.ps1 @@ -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 { From 7de051e488adbdaaddbc6922a717c5b85f6f15c0 Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Thu, 16 May 2024 11:33:37 -0500 Subject: [PATCH 3/3] docs: add example of markdown file output --- README.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 482d067..e9e4cb9 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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: @@ -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: @@ -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: @@ -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