diff --git a/.github/actions/verify-submodule-pull-request/Check-Parent.ps1 b/.github/actions/verify-submodule-pull-request/Check-Parent.ps1 index cc60b4aef..46841cff6 100644 --- a/.github/actions/verify-submodule-pull-request/Check-Parent.ps1 +++ b/.github/actions/verify-submodule-pull-request/Check-Parent.ps1 @@ -1,21 +1,18 @@ -param( +param( [string] $Repository, [string] $Branch ) -$requestParameters = @{ - Uri = "https://api.github.com/repos/$Repository/pulls?state=open&per_page=100" - Method = "Get" - Headers = @{ Accept = "application/vnd.github.v3+json" } -} -$titles = (Invoke-WebRequest @requestParameters).Content | ConvertFrom-Json | ForEach-Object { $PSItem.title } - if (!($Branch -match '(\w+-\d+)')) { exit } +$url = "https://api.github.com/repos/$Repository/pulls?state=open&per_page=100" +$response = Invoke-WebRequest $url -Headers (Get-GitHubApiAuthorizationHeader) -Method Get +$titles = $response.Content | ConvertFrom-Json | ForEach-Object { $PSItem.title } + $issueCode = $matches[0] $lookFor = "${issueCode}:" if (($titles | Where-Object { $PSItem -and $PSItem.Trim().StartsWith($lookFor) }).Count -gt 0) { exit 0 } -Set-Failed "Couldn't find any pull request whose title starts with `"$lookFor`" in $Repository. Please create one." \ No newline at end of file +Set-Failed "Couldn't find any pull request whose title starts with `"$lookFor`" in $Repository. Please create one." diff --git a/.github/actions/verify-submodule-pull-request/action.yml b/.github/actions/verify-submodule-pull-request/action.yml index f1f6a8632..4d1f32a46 100644 --- a/.github/actions/verify-submodule-pull-request/action.yml +++ b/.github/actions/verify-submodule-pull-request/action.yml @@ -15,11 +15,9 @@ inputs: runs: using: "composite" steps: - - name: Setup and Print PR Title + - name: Setup Scripts shell: pwsh run: | - Write-Output "Pull Request Title: ${{ inputs.title }}" - "${{ github.action_path }}" >> $Env:GITHUB_PATH (Resolve-Path "${{ github.action_path }}/../../../Scripts").Path >> $Env:GITHUB_PATH diff --git a/.github/workflows/validate-submodule-pull-request.yml b/.github/workflows/validate-submodule-pull-request.yml index d662cc687..45cf8d269 100644 --- a/.github/workflows/validate-submodule-pull-request.yml +++ b/.github/workflows/validate-submodule-pull-request.yml @@ -30,6 +30,8 @@ jobs: - name: Ensure Parent PR Exists if: github.event.pull_request != '' uses: Lombiq/GitHub-Actions/.github/actions/verify-submodule-pull-request@dev + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: title: ${{ github.event.pull_request.title }} repository: ${{ inputs.repository }}