Skip to content

Commit fa69e55

Browse files
authored
Merge pull request #2 from ShivamHS/script-changes
rolled back previous changes
2 parents 158f58e + 623088b commit fa69e55

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ branding:
77
color: blue
88

99
inputs:
10+
token:
11+
description: 'GitHub token with repo scope.'
12+
required: true
13+
owner:
14+
description: 'owner of repo.'
15+
required: true
16+
repo:
17+
description: 'The name of the repository.'
18+
required: true
1019
pattern:
1120
description: 'Keyword to match for deletion.'
1221
required: true
@@ -15,4 +24,7 @@ runs:
1524
using: docker
1625
image: Dockerfile
1726
args:
27+
- ${{ inputs.token }}
28+
- ${{ inputs.owner }}
29+
- ${{ inputs.repo }}
1830
- ${{ inputs.pattern }}

pr-naming.ps1

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11

22
param (
3-
[string]$pattern = $env:INPUT_PATTERN
3+
[string]$Token = $env:INPUT_TOKEN,
4+
[string]$Owner = $env:INPUT_OWNER,
5+
[string]$Repo = $env:INPUT_REPO,
6+
[string]$Pattern = $env:INPUT_PATTERN
47
)
5-
$ErrorActionPreference = "Stop"
6-
try {
7-
8-
$githubContext = $env:GITHUB_CONTEXT | ConvertFrom-Json
9-
10-
$prTitle = $githubContext.event.pull_request.title
11-
if (-not ($prTitle -match $pattern)) {
12-
throw "PR title '$prTitle' does not match the pattern '$pattern'."
13-
} else {
14-
Write-Output "PR title '$prTitle' matches the pattern '$pattern'."
15-
}
16-
} catch {
17-
Write-Error $_.Exception.Message
18-
exit 1
8+
9+
10+
$headers = @{
11+
Authorization = "Bearer $Token"
1912
}
13+
14+
Write-Host "$Token, $Owner, $Pattern, $Repo"
15+
16+
$prUrl = "https://api.github.com/repos/$Owner/$Repo/pulls"
17+
#$prs = Invoke-RestMethod -Uri $prUrl -Headers $headers
18+
$pr = Invoke-RestMethod -Uri $prUrl -Headers $headers
19+
# foreach ($pr in $prs) {
20+
$prTitle = $pr.title
21+
if ($prTitle -match $Pattern) {
22+
Write-Host "PR #$($pr.number): Title is valid: $prTitle"
23+
} else {
24+
Write-Host "PR #$($pr.number): Invalid title: $prTitle"
25+
}
26+
#}

0 commit comments

Comments
 (0)