Skip to content

Commit e996ca1

Browse files
authored
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
1 parent 3424977 commit e996ca1

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

.github/workflows/updater.yml

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -145,39 +145,24 @@ jobs:
145145
Write-Output "::warning::Target branch '$prBranch' has been changed manually - skipping updater to avoid overwriting these changes."
146146
}
147147
148-
- name: Fetch an existing PR
149-
if: ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.root.outputs.changed == 'false') }}
150-
uses: octokit/request-action@89697eb6635e52c6e1e5559f15b5c91ba5100cb0 # v2.1.9
151-
id: existing-pr-request
152-
with:
153-
route: GET /repos/${{ github.repository }}/pulls?base={base}&head={head}
154-
head: '${{ github.repository }}:${{ steps.root.outputs.prBranch }}'
155-
base: '${{ steps.root.outputs.baseBranch }}'
156-
env:
157-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158-
159148
- name: Parse the existing PR URL
160149
if: ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.root.outputs.changed == 'false') }}
161150
id: existing-pr
151+
env:
152+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
162153
run: |
163-
$data = @'
164-
${{ steps.existing-pr-request.outputs.data }}
165-
'@
166-
167-
$prCount = $($data | jq '. | length')
168-
169-
if ($prCount -eq '0')
154+
$urls = @(gh api 'repos/${{ github.repository }}/pulls?base=${{ steps.root.outputs.baseBranch }}&head=${{ github.repository_owner }}:${{ steps.root.outputs.prBranch }}' --jq '.[].html_url')
155+
if ($urls.Length -eq 0)
170156
{
171157
"url=" | Tee-Object $env:GITHUB_OUTPUT -Append
172158
}
173-
elseif ($prCount -eq '1')
159+
elseif ($urls.Length -eq 1)
174160
{
175-
$url = $($data | Select-String '"html_url": +"(.*/pull/.*)"').Matches[0].Groups[1].Value
176-
"url=$url" | Tee-Object $env:GITHUB_OUTPUT -Append
161+
"url=$($urls[0])" | Tee-Object $env:GITHUB_OUTPUT -Append
177162
}
178163
else
179164
{
180-
throw "Unexpected number of PRs matched: $prCount"
165+
throw "Unexpected number of PRs matched ($($urls.Length)): $urls"
181166
}
182167
183168
- run: git --no-pager diff

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Changes
6+
7+
- Remove `octokit/request-action` dependency in favor of using `gh api` ([#74](https://github.com/getsentry/github-workflows/pull/74))
8+
59
### Fixes
610

711
- Bump updater action dependency to fix an issue when creating/updating a PR ([#71](https://github.com/getsentry/github-workflows/pull/71))

0 commit comments

Comments
 (0)