From e996ca1595a135881559f28057b0cfb2906359c2 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:36:07 +0100 Subject: [PATCH] chore: remove octokit action dependency (#74) * chore: remove octokit action dependency * fix API request * chore: update changelog * logs * add missing token * fix filtering and cleanup --- .github/workflows/updater.yml | 29 +++++++---------------------- CHANGELOG.md | 4 ++++ 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index 185da71..7b70200 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -145,39 +145,24 @@ jobs: Write-Output "::warning::Target branch '$prBranch' has been changed manually - skipping updater to avoid overwriting these changes." } - - name: Fetch an existing PR - if: ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.root.outputs.changed == 'false') }} - uses: octokit/request-action@89697eb6635e52c6e1e5559f15b5c91ba5100cb0 # v2.1.9 - id: existing-pr-request - with: - route: GET /repos/${{ github.repository }}/pulls?base={base}&head={head} - head: '${{ github.repository }}:${{ steps.root.outputs.prBranch }}' - base: '${{ steps.root.outputs.baseBranch }}' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Parse the existing PR URL if: ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.root.outputs.changed == 'false') }} id: existing-pr + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - $data = @' - ${{ steps.existing-pr-request.outputs.data }} - '@ - - $prCount = $($data | jq '. | length') - - if ($prCount -eq '0') + $urls = @(gh api 'repos/${{ github.repository }}/pulls?base=${{ steps.root.outputs.baseBranch }}&head=${{ github.repository_owner }}:${{ steps.root.outputs.prBranch }}' --jq '.[].html_url') + if ($urls.Length -eq 0) { "url=" | Tee-Object $env:GITHUB_OUTPUT -Append } - elseif ($prCount -eq '1') + elseif ($urls.Length -eq 1) { - $url = $($data | Select-String '"html_url": +"(.*/pull/.*)"').Matches[0].Groups[1].Value - "url=$url" | Tee-Object $env:GITHUB_OUTPUT -Append + "url=$($urls[0])" | Tee-Object $env:GITHUB_OUTPUT -Append } else { - throw "Unexpected number of PRs matched: $prCount" + throw "Unexpected number of PRs matched ($($urls.Length)): $urls" } - run: git --no-pager diff diff --git a/CHANGELOG.md b/CHANGELOG.md index bdb4941..e912bd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Changes + +- Remove `octokit/request-action` dependency in favor of using `gh api` ([#74](https://github.com/getsentry/github-workflows/pull/74)) + ### Fixes - Bump updater action dependency to fix an issue when creating/updating a PR ([#71](https://github.com/getsentry/github-workflows/pull/71))