Skip to content

Commit f6643ab

Browse files
🩹 [Patch]: Use GitHub-Script action (#4)
## Description This pull request changes the action to use the `GitHub-Script` action, to make use of built in functions in the GitHub PowerShell module: * [`action.yml`](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6L17-R28): Modified the `Get-IssueFormData` step to use the `PSModule/GitHub-Script@v1` module and updated the method for setting the output data. * [`scripts/main.ps1`](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011L117-R128): Replaced direct output commands with `LogGroup` and `Set-GitHubOutput` functions. * [`.github/workflows/Action-Test.yml`](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4L30-R43): Replaced inline PowerShell scripts with the `PSModule/GitHub-Script@v1` module to use the built in functionality of the GitHub PowerShell module. * [`README.md`](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L84-R84): Updated the `Get-IssueFormData` module from version `v0` to `v1`. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 453d090 commit f6643ab

5 files changed

Lines changed: 26 additions & 32 deletions

File tree

.github/workflows/Action-Test.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,15 @@ jobs:
2727

2828
- name: Get issue file content
2929
id: GetIssueFileContent
30-
shell: pwsh
31-
run: |
32-
$issueFileContent = Get-Content -Path tests/IssueBody.md -Raw
33-
34-
$EOF = -join (1..15 | ForEach {[char]((48..57)+(65..90)+(97..122) | Get-Random)})
35-
"issueFileContent<<$EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
36-
$issueFileContent | Out-File -FilePath $env:GITHUB_OUTPUT -Append
37-
"$EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
38-
39-
- uses: PSModule/Debug@v0
40-
if: always()
30+
uses: PSModule/GitHub-Script@v1
31+
with:
32+
Script: . '.\tests\Get-IssueFileContent.ps1'
4133

4234
- name: Action-Test
4335
id: Action-Test
4436
uses: ./
4537
with:
46-
IssueBody: ${{ steps.GetIssueFileContent.outputs.issueFileContent }}
38+
IssueBody: ${{ fromJson(steps.GetIssueFileContent.outputs.result).issueFileContent }}
4739

4840
- name: Action-Test-Results
4941
shell: pwsh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
steps:
8282
- name: Get-IssueFormData
8383
id: Get-IssueFormData
84-
uses: PSModule/Get-IssueFormData@v0
84+
uses: PSModule/Get-IssueFormData@v1
8585

8686
- name: Print data
8787
shell: pwsh

action.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ inputs:
1414
outputs:
1515
data:
1616
description: The data from the issue body
17-
value: ${{ steps.Get-IssueFormData.outputs.data }}
17+
value: ${{ fromJson(steps.Get-IssueFormData.outputs.result).data }}
1818

1919
runs:
2020
using: composite
2121
steps:
2222
- name: Get-IssueFormData
2323
id: Get-IssueFormData
24-
shell: pwsh
24+
uses: PSModule/GitHub-Script@v1
2525
env:
2626
GITHUB_ACTION_INPUT_IssueBody: ${{ inputs.IssueBody }}
27-
run: |
28-
# Get-IssueFormData
29-
. "${{ github.action_path }}\scripts\main.ps1" -Verbose
27+
with:
28+
Script: . (Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1')

scripts/main.ps1

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,17 @@ filter Process-IssueBody {
114114
$data
115115
}
116116

117-
Write-Host '::group::Issue Body'
118-
$IssueBody
119-
Write-Host '::endgroup::'
120-
121-
Write-Host '::group::Issue Body Split'
122-
# Read the content of the file
123-
124-
$data = $IssueBody | Parse-IssueBody | Process-IssueBody
125-
# Output the results
126-
$data | Format-Table -AutoSize
117+
LogGroup 'Issue Body - Raw' {
118+
Write-Output $IssueBody
119+
}
127120

128-
$data = $data | ConvertTo-Json -Compress
129-
$data
130-
"data=$data" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
121+
LogGroup 'Issue Body - Object' {
122+
$data = $IssueBody | Parse-IssueBody | Process-IssueBody
123+
$data | Format-Table -AutoSize
124+
}
131125

132-
Write-Host '::endgroup::'
126+
LogGroup 'Issue Body - JSON' {
127+
$data = $data | ConvertTo-Json -Compress
128+
Write-Output $data
129+
Set-GitHubOutput -Name 'data' -Value $data
130+
}

tests/Get-IssueFileContent.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
LogGroup 'Get Issue File Content' {
2+
$issueFileContent = Get-Content -Path tests/IssueBody.md -Raw
3+
$issueFileContent
4+
Set-GitHubOutput -Name 'issueFileContent' -Value $issueFileContent
5+
}

0 commit comments

Comments
 (0)