Skip to content

Commit bbb4e4e

Browse files
🩹 [Patch]: Add try/finally blocks (#38)
## Description This pull request includes changes to the `action.yml` and the addition of a new script file to improve the robustness and cleanliness of the GitHub Action's execution. Improvements to GitHub Action execution: * `action.yml`: Modified the `run` block to include a `try` block for executing scripts and a `finally` block to ensure the cleanup script is always executed. This change enhances the robustness of the script execution. Addition of cleanup script: * `scripts/clean.ps1`: Added a new PowerShell script to handle cleanup tasks, including logging debug information and resetting environment variables. This ensures that the environment is properly cleaned up after the action runs. ## 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 18e354f commit bbb4e4e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ runs:
7676
GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }}
7777
run: |
7878
# GitHub-Script
79-
. ${{ github.action_path }}\scripts\init.ps1
80-
. ${{ github.action_path }}\scripts\info.ps1
81-
${{ inputs.Script }}
82-
. ${{ github.action_path }}\scripts\outputs.ps1
79+
try {
80+
${{ github.action_path }}/scripts/init.ps1
81+
${{ github.action_path }}/scripts/info.ps1
82+
${{ inputs.Script }}
83+
${{ github.action_path }}/scripts/outputs.ps1
84+
}
85+
finally {
86+
${{ github.action_path }}/scripts/clean.ps1
87+
}

scripts/clean.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Write-Debug "Cleaning up..."
2+
Write-Debug "LASTEXITCODE: $LASTEXITCODE"
3+
Write-Debug "PSMODULE_GITHUB_SCRIPT: $env:PSMODULE_GITHUB_SCRIPT"
4+
$env:PSMODULE_GITHUB_SCRIPT = $false
5+
Write-Debug "PSMODULE_GITHUB_SCRIPT: $env:PSMODULE_GITHUB_SCRIPT"

0 commit comments

Comments
 (0)