-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created pswh,dockerfile,action and readme
- Loading branch information
0 parents
commit 19e2e52
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine3.13 | ||
|
||
COPY pr-naming.ps1 / | ||
|
||
ENTRYPOINT [ "pwsh", "-File", "/pr-naming.ps1"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# PR Naming | ||
This will take care of your PR naming, if it is matched with the regex pattern you have given or not | ||
|
||
# Example | ||
```yaml | ||
name: Delete Tag | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, edited] | ||
branches: | ||
- master | ||
|
||
jobs: | ||
pr-title-check:: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
|
||
- name: Check PR title format | ||
uses: ShivamHS/PR-naming@v1.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
repo: your-repo-name | ||
owner: repo-owner | ||
pattern: enter the regex pattern for validation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: 'PR Nomencleture' | ||
|
||
description: 'Checks if PR is named as per input pattern' | ||
author: Shivam | ||
branding: | ||
icon: clipboard | ||
color: blue | ||
|
||
inputs: | ||
token: | ||
description: 'GitHub token with repo scope.' | ||
required: true | ||
owner: | ||
description: 'owner of repo.' | ||
required: true | ||
repo: | ||
description: 'The name of the repository.' | ||
required: true | ||
pattern: | ||
description: 'Keyword to match for deletion.' | ||
required: true | ||
|
||
runs: | ||
using: docker | ||
image: Dockerfile | ||
args: | ||
- ${{ inputs.token }} | ||
- ${{ inputs.owner }} | ||
- ${{ inputs.repo }} | ||
- ${{ inputs.pattern }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
param ( | ||
[string]$Token = $env:INPUT_TOKEN, | ||
[string]$Owner = $env:INPUT_OWNER, | ||
[string]$Repo = $env:INPUT_REPO, | ||
[string]$Pattern = $env:INPUT_PATTERN | ||
) | ||
|
||
|
||
$headers = @{ | ||
Authorization = "Bearer $Token" | ||
} | ||
|
||
Write-Host "$Token, $Owner, $Pattern, $Repo" | ||
|
||
$prUrl = "https://api.github.com/repos/$Owner/$Repo/pulls" | ||
$prs = Invoke-RestMethod -Uri $prUrl -Headers $headers | ||
|
||
foreach ($pr in $prs) { | ||
$prTitle = $pr.title | ||
if ($prTitle -match $Pattern) { | ||
Write-Host "PR #$($pr.number): Title is valid: $prTitle" | ||
} else { | ||
Write-Host "PR #$($pr.number): Invalid title: $prTitle" | ||
} | ||
} |