Skip to content

Commit 7291b83

Browse files
committed
CI: Publish a GitHub Action to install Pog to a pipeline
1 parent 287fc81 commit 7291b83

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'Install Pog'
2+
description: 'Install the Pog package manager (https://github.com/MatejKafka/Pog).'
3+
inputs:
4+
path:
5+
description: 'Path to the directory where Pog is installed.'
6+
required: false
7+
default: D:\Pog
8+
version:
9+
description: 'Pog version to install. Defaults to the latest available version.'
10+
required: false
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Install Pog
15+
shell: pwsh
16+
run: |
17+
$GitHubToken = ConvertTo-SecureString -AsPlainText -Force "${{ secrets.GITHUB_TOKEN }}"
18+
& $env:GITHUB_ACTION_PATH\install-pog.ps1 $env:POG_PATH -GitHubToken $GitHubToken
19+
env:
20+
POG_PATH: ${{ inputs.path }}
21+
POG_VERSION: ${{ inputs.version }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
param(
2+
[Parameter(Mandatory)]
3+
[string]
4+
$PogPath,
5+
[version]
6+
$Version,
7+
[securestring]
8+
$GithubToken
9+
)
10+
11+
Set-StrictMode -Version 3
12+
$ErrorActionPreference = "Stop"
13+
$PSNativeCommandUseErrorActionPreference = $true
14+
15+
$ExtraArgs = if ($GitHubToken) {@{Authentication = "Bearer"; Token = $GitHubToken}}
16+
$Endpoint = if ($Version) {"tags/v$Version"} else {"latest"}
17+
$ReleaseUrl = (Invoke-RestMethod @ExtraArgs "https://api.github.com/repos/MatejKafka/Pog/releases/$Endpoint").assets.browser_download_url
18+
19+
Write-Host "Installing Pog from '$ReleaseUrl'..."
20+
$ArchivePath = "${PogPath}.zip"
21+
iwr $ReleaseUrl -OutFile $ArchivePath
22+
23+
# unpack Pog, tar is much faster than Expand-Archive
24+
$null = mkdir $PogPath
25+
tar -xf $ArchivePath --directory $PogPath
26+
27+
# setup Pog
28+
& $PogPath\Pog\setup.ps1 -Enable None
29+
30+
# propagate PATH and PSModulePath for the following steps
31+
Add-Content $env:GITHUB_PATH (Resolve-Path $PogPath\Pog\data\package_bin)
32+
Add-Content $env:GITHUB_ENV "PSModulePath=$env:PSModulePath"

0 commit comments

Comments
 (0)