Skip to content

Commit a4eccb4

Browse files
🩹 [Patch]: Using GitHub-Script action (#3)
## Description - Using GitHub-Script action ## 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 45dbe9f commit a4eccb4

File tree

5 files changed

+117
-79
lines changed

5 files changed

+117
-79
lines changed

.github/workflows/Linter.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ jobs:
2727
uses: super-linter/super-linter/slim@latest
2828
env:
2929
GITHUB_TOKEN: ${{ github.token }}
30+
VALIDATE_MARKDOWN_PRETTIER: false
31+
VALIDATE_YAML_PRETTIER: false

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
# Template-action
1+
# Debug
22

3-
A template repository for GitHub Actions
3+
Gets debug information about the environment.
44

5-
Uses all the contexts and environment variables
5+
Uses all the contexts, environment variables and PowerShell variables and modules.
66

77
- [Contexts | GitHub Docs](https://docs.github.com/en/actions/learn-github-actions/contexts)
88
- [Variables | GitHub Docs](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables)
99

1010
## Usage
1111

12-
### Inputs
13-
14-
### Secrets
15-
16-
### Outputs
17-
1812
### Example
1913

14+
#### Example 1: Get debug information
15+
2016
```yaml
21-
Example here
17+
jobs:
18+
Get-Debug:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Debug
22+
uses: PSModule/Debug@v1
2223
```

action.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ runs:
1010
using: composite
1111
steps:
1212
- name: Debug
13-
shell: pwsh
13+
uses: PSModule/GitHub-Script@v1
1414
env:
1515
CONTEXT_GITHUB: ${{ toJson(github) }}
1616
CONTEXT_ENV: ${{ toJson(env) }}
@@ -24,6 +24,9 @@ runs:
2424
CONTEXT_MATRIX: ${{ toJson(matrix) }}
2525
# CONTEXT_NEEDS: ${{ toJson(needs) }}
2626
CONTEXT_INPUTS: ${{ toJson(inputs) }}
27-
run: |
28-
# Debug environment
29-
. "$env:GITHUB_ACTION_PATH\scripts\main.ps1" -Verbose
27+
with:
28+
Debug: true
29+
Verbose: true
30+
Script: |
31+
# Debug environment
32+
. "${{ github.action_path }}\scripts\main.ps1" -Verbose

scripts/main.ps1

Lines changed: 97 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,119 @@
11
[CmdletBinding()]
22
param()
33

4-
$n = [System.Environment]::NewLine
5-
6-
74
$CONTEXT_GITHUB = $env:CONTEXT_GITHUB | ConvertFrom-Json -Depth 100
8-
'::group::Context: [GITHUB]'
9-
$CONTEXT_GITHUB | ConvertTo-Json -Depth 100
105

11-
'::group::Context: [GITHUB_EVENT]'
12-
$CONTEXT_GITHUB.event | ConvertTo-Json -Depth 100
6+
LogGroup 'Context: [GITHUB]' {
7+
$CONTEXT_GITHUB | ConvertTo-Json -Depth 100
8+
}
139

14-
'::group::Context: [GITHUB_EVENT_ENTERPRISE]'
15-
$CONTEXT_GITHUB | ConvertTo-Json -Depth 100
10+
LogGroup 'Context: [GITHUB_EVENT]' {
11+
$CONTEXT_GITHUB.event | ConvertTo-Json -Depth 100
12+
}
1613

17-
'::group::Context: [GITHUB_EVENT_ORGANIZATION]'
18-
$CONTEXT_GITHUB.event.organization | ConvertTo-Json -Depth 100
14+
LogGroup 'Context: [GITHUB_EVENT_ENTERPRISE]' {
15+
$CONTEXT_GITHUB | ConvertTo-Json -Depth 100
16+
}
1917

20-
'::group::Context: [GITHUB_EVENT_REPOSITORY]'
21-
$CONTEXT_GITHUB.event.repository | ConvertTo-Json -Depth 100
18+
LogGroup 'Context: [GITHUB_EVENT_ORGANIZATION]' {
19+
$CONTEXT_GITHUB.event.organization | ConvertTo-Json -Depth 100
20+
}
2221

23-
'::group::Context: [ENV]'
24-
$env:CONTEXT_ENV
22+
LogGroup 'Context: [GITHUB_EVENT_REPOSITORY]' {
23+
$CONTEXT_GITHUB.event.repository | ConvertTo-Json -Depth 100
24+
}
2525

26-
# '::group::Context: [VARS]'
26+
LogGroup 'Context: [ENV]' {
27+
$env:CONTEXT_ENV
28+
}
29+
30+
# LogGroup 'Context: [VARS]' {
2731
# $env:CONTEXT_VARS
32+
# }
2833

29-
'::group::Context: [JOB]'
30-
$env:CONTEXT_JOB
34+
LogGroup 'Context: [JOB]' {
35+
$env:CONTEXT_JOB
36+
}
3137

32-
# '::group::Context: [JOBS]'
38+
# LogGroup 'Context: [JOBS]' {
3339
# $env:CONTEXT_JOBS
40+
# }
3441

35-
'::group::Context: [STEPS]'
36-
$env:CONTEXT_STEPS
42+
LogGroup 'Context: [STEPS]' {
43+
$env:CONTEXT_STEPS
44+
}
3745

38-
'::group::Context: [RUNNER]'
39-
$env:CONTEXT_RUNNER
46+
LogGroup 'Context: [RUNNER]' {
47+
$env:CONTEXT_RUNNER
48+
}
4049

41-
# '::group::Context: [SECRETS]'
50+
# LogGroup 'Context: [SECRETS]' {
4251
# $env:CONTEXT_SECRETS
52+
# }
4353

44-
'::group::Context: [STRATEGY]'
45-
$env:CONTEXT_STRATEGY
54+
LogGroup 'Context: [STRATEGY]' {
55+
$env:CONTEXT_STRATEGY
56+
}
4657

47-
'::group::Context: [MATRIX]'
48-
$env:CONTEXT_MATRIX
58+
LogGroup 'Context: [MATRIX]' {
59+
$env:CONTEXT_MATRIX
60+
}
4961

50-
# '::group::Context: [NEEDS]'
62+
# LogGroup 'Context: [NEEDS]' {
5163
# $env:CONTEXT_NEEDS
52-
53-
'::group::Context: [INPUTS]'
54-
$env:CONTEXT_INPUTS
55-
56-
"::group::File system at [$pwd]"
57-
Get-ChildItem -Path . | Select-Object FullName | Sort-Object FullName | Format-Table -AutoSize -Wrap
58-
59-
'::group::Environment Variables'
60-
Get-ChildItem env: | Where-Object {$_.Name -notlike 'CONTEXT_*'} | Sort-Object Name | Format-Table -AutoSize -Wrap
61-
62-
"::group::PowerShell variables"
63-
Get-Variable | Where-Object {$_.Name -notlike 'CONTEXT_*'} | Sort-Object Name | Format-Table -AutoSize -Wrap
64-
65-
"::group::PSVersionTable"
66-
$PSVersionTable | Select-Object *
67-
68-
"::group::ExecutionContext"
69-
$ExecutionContext | Select-Object *
70-
71-
"::group::Host"
72-
$Host | Select-Object *
73-
74-
"::group::MyInvocation"
75-
$MyInvocation | Select-Object *
76-
77-
"::group::PSCmdlet"
78-
$PSCmdlet | Select-Object *
79-
80-
"::group::PSSessionOption"
81-
$PSSessionOption | Select-Object *
82-
83-
"::group::PSStyle"
84-
$PSStyle | Select-Object *
64+
# }
65+
LogGroup 'Context: [INPUTS]' {
66+
$env:CONTEXT_INPUTS
67+
}
68+
69+
LogGroup "File system at [$pwd]" {
70+
Get-ChildItem -Path . | Select-Object FullName | Sort-Object FullName | Format-Table -AutoSize -Wrap
71+
}
72+
73+
LogGroup 'Environment Variables' {
74+
Get-ChildItem env: | Where-Object { $_.Name -notlike 'CONTEXT_*' } | Sort-Object Name | Format-Table -AutoSize -Wrap
75+
}
76+
77+
LogGroup 'PowerShell variables' {
78+
Get-Variable | Where-Object { $_.Name -notlike 'CONTEXT_*' } | Sort-Object Name | Format-Table -AutoSize -Wrap
79+
}
80+
81+
LogGroup 'PSVersionTable' {
82+
$PSVersionTable | Select-Object * | Format-List
83+
}
84+
85+
LogGroup 'Installed Modules - List' {
86+
$modules = Get-PSResource | Sort-Object -Property Name
87+
$modules | Select-Object Name, Version, CompanyName, Author | Format-Table -AutoSize -Wrap
88+
}
89+
90+
$modules.Name | Select-Object -Unique | ForEach-Object {
91+
$name = $_
92+
LogGroup "Installed Modules - Details - [$name]" {
93+
$modules | Where-Object Name -EQ $name | Select-Object * | Format-List
94+
}
95+
}
96+
97+
LogGroup 'ExecutionContext' {
98+
$ExecutionContext | Select-Object * | Format-List
99+
}
100+
101+
LogGroup 'Host' {
102+
$Host | Select-Object * | Format-List
103+
}
104+
105+
LogGroup 'MyInvocation' {
106+
$MyInvocation | Select-Object * | Format-List
107+
}
108+
109+
LogGroup 'PSCmdlet' {
110+
$PSCmdlet | Select-Object * | Format-List
111+
}
112+
113+
LogGroup 'PSSessionOption' {
114+
$PSSessionOption | Select-Object * | Format-List
115+
}
116+
117+
LogGroup 'PSStyle' {
118+
$PSStyle | Select-Object * | Format-List
119+
}

tests/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)